@hivemoot-dev/cli 0.1.6 → 0.1.7
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/index.js +163 -93
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -278,22 +278,76 @@ async function fetchIssues(repo, limit = 200) {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// src/github/pulls.ts
|
|
281
|
+
async function fetchLatestCommitDates(repo, limit) {
|
|
282
|
+
const query = `
|
|
283
|
+
query($owner: String!, $name: String!, $pageSize: Int!, $cursor: String) {
|
|
284
|
+
repository(owner: $owner, name: $name) {
|
|
285
|
+
pullRequests(first: $pageSize, after: $cursor, states: OPEN, orderBy: {field: CREATED_AT, direction: DESC}) {
|
|
286
|
+
pageInfo { hasNextPage endCursor }
|
|
287
|
+
nodes {
|
|
288
|
+
number
|
|
289
|
+
commits(last: 1) { nodes { commit { committedDate } } }
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}`;
|
|
294
|
+
const PAGE_SIZE = 100;
|
|
295
|
+
const map = /* @__PURE__ */ new Map();
|
|
296
|
+
let remaining = limit;
|
|
297
|
+
let cursor = null;
|
|
298
|
+
while (remaining > 0) {
|
|
299
|
+
const pageSize = Math.min(remaining, PAGE_SIZE);
|
|
300
|
+
const args = [
|
|
301
|
+
"api",
|
|
302
|
+
"graphql",
|
|
303
|
+
"-F",
|
|
304
|
+
`owner=${repo.owner}`,
|
|
305
|
+
"-F",
|
|
306
|
+
`name=${repo.repo}`,
|
|
307
|
+
"-F",
|
|
308
|
+
`pageSize=${pageSize}`,
|
|
309
|
+
"-f",
|
|
310
|
+
`query=${query}`
|
|
311
|
+
];
|
|
312
|
+
if (cursor) {
|
|
313
|
+
args.push("-F", `cursor=${cursor}`);
|
|
314
|
+
} else {
|
|
315
|
+
args.push("-f", "cursor=");
|
|
316
|
+
}
|
|
317
|
+
const json = await gh(args);
|
|
318
|
+
const data = JSON.parse(json);
|
|
319
|
+
const prs = data?.data?.repository?.pullRequests;
|
|
320
|
+
const nodes = prs?.nodes ?? [];
|
|
321
|
+
for (const pr of nodes) {
|
|
322
|
+
const commit = pr.commits.nodes[0];
|
|
323
|
+
if (commit) map.set(pr.number, commit.commit.committedDate);
|
|
324
|
+
}
|
|
325
|
+
remaining -= nodes.length;
|
|
326
|
+
const hasNext = prs?.pageInfo?.hasNextPage === true;
|
|
327
|
+
if (!hasNext || nodes.length === 0) break;
|
|
328
|
+
cursor = prs.pageInfo.endCursor;
|
|
329
|
+
}
|
|
330
|
+
return map;
|
|
331
|
+
}
|
|
281
332
|
async function fetchPulls(repo, limit = 200) {
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
333
|
+
const [listJson, commitDates] = await Promise.all([
|
|
334
|
+
gh([
|
|
335
|
+
"pr",
|
|
336
|
+
"list",
|
|
337
|
+
"-R",
|
|
338
|
+
`${repo.owner}/${repo.repo}`,
|
|
339
|
+
"--state",
|
|
340
|
+
"open",
|
|
341
|
+
"--json",
|
|
342
|
+
"number,title,state,author,labels,comments,reviews,createdAt,updatedAt,url,isDraft,reviewDecision,mergeable,statusCheckRollup,closingIssuesReferences",
|
|
343
|
+
"--limit",
|
|
344
|
+
String(limit)
|
|
345
|
+
]),
|
|
346
|
+
fetchLatestCommitDates(repo, limit)
|
|
293
347
|
]);
|
|
294
348
|
let parsed;
|
|
295
349
|
try {
|
|
296
|
-
parsed = JSON.parse(
|
|
350
|
+
parsed = JSON.parse(listJson);
|
|
297
351
|
} catch {
|
|
298
352
|
throw new CliError(
|
|
299
353
|
"Failed to parse pull requests response from gh CLI",
|
|
@@ -308,7 +362,12 @@ async function fetchPulls(repo, limit = 200) {
|
|
|
308
362
|
1
|
|
309
363
|
);
|
|
310
364
|
}
|
|
311
|
-
|
|
365
|
+
const prs = parsed;
|
|
366
|
+
for (const pr of prs) {
|
|
367
|
+
const date = commitDates.get(pr.number);
|
|
368
|
+
pr.commits = date ? [{ committedDate: date }] : [];
|
|
369
|
+
}
|
|
370
|
+
return prs;
|
|
312
371
|
}
|
|
313
372
|
|
|
314
373
|
// src/github/user.ts
|
|
@@ -340,10 +399,12 @@ function timeAgo(dateStr, now) {
|
|
|
340
399
|
const hours = Math.floor(ms / 36e5);
|
|
341
400
|
const days = Math.floor(ms / 864e5);
|
|
342
401
|
if (minutes < 1) return "just now";
|
|
343
|
-
if (minutes
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
402
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
403
|
+
if (hours < 24) {
|
|
404
|
+
const remainingMinutes = minutes % 60;
|
|
405
|
+
if (remainingMinutes === 0) return `${hours}h ago`;
|
|
406
|
+
return `${hours}h${remainingMinutes}m ago`;
|
|
407
|
+
}
|
|
347
408
|
if (days === 1) return "yesterday";
|
|
348
409
|
if (days < 7) return `${days} days ago`;
|
|
349
410
|
if (days < 14) return "1 week ago";
|
|
@@ -354,10 +415,6 @@ function timeAgo(dateStr, now) {
|
|
|
354
415
|
if (years === 1) return "1 year ago";
|
|
355
416
|
return `${years} years ago`;
|
|
356
417
|
}
|
|
357
|
-
function daysSince(dateStr, now) {
|
|
358
|
-
const diff = now.getTime() - new Date(dateStr).getTime();
|
|
359
|
-
return Math.max(0, Math.floor(diff / (1e3 * 60 * 60 * 24)));
|
|
360
|
-
}
|
|
361
418
|
function hasCIFailure(pr) {
|
|
362
419
|
if (!pr.statusCheckRollup) return false;
|
|
363
420
|
return pr.statusCheckRollup.some((check) => {
|
|
@@ -403,60 +460,42 @@ function changesRequestedCount(pr) {
|
|
|
403
460
|
}
|
|
404
461
|
return count;
|
|
405
462
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
(latest, c) => c.createdAt > latest.createdAt ? c : latest
|
|
414
|
-
).createdAt;
|
|
415
|
-
}
|
|
416
|
-
function generateAlerts(issues, prs, now = /* @__PURE__ */ new Date()) {
|
|
417
|
-
const alerts = [];
|
|
418
|
-
for (const issue of issues) {
|
|
419
|
-
if (!hasLabel(issue.labels, "discuss") && !hasExactLabel(issue.labels, "phase:discussion")) continue;
|
|
420
|
-
const lastComment = lastCommentDate(issue);
|
|
421
|
-
const referenceDate = lastComment ?? issue.createdAt;
|
|
422
|
-
const days = daysSince(referenceDate, now);
|
|
423
|
-
if (days >= STALE_DISCUSSION_DAYS) {
|
|
424
|
-
alerts.push({
|
|
425
|
-
icon: "\u26A0\uFE0F",
|
|
426
|
-
message: `#${issue.number} in discussion ${days} days, no recent comments`
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
for (const issue of issues) {
|
|
431
|
-
if (hasExactLabel(issue.labels, "needs:human")) {
|
|
432
|
-
alerts.push({
|
|
433
|
-
icon: "\u{1F6D1}",
|
|
434
|
-
message: `#${issue.number} needs human attention`
|
|
435
|
-
});
|
|
463
|
+
function reviewContext(pr, currentUser, now) {
|
|
464
|
+
let latestState;
|
|
465
|
+
let latestTime;
|
|
466
|
+
for (const review of pr.reviews ?? []) {
|
|
467
|
+
if (review.author?.login === currentUser) {
|
|
468
|
+
latestState = review.state;
|
|
469
|
+
latestTime = review.submittedAt;
|
|
436
470
|
}
|
|
437
471
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
472
|
+
if (!latestState) return null;
|
|
473
|
+
const stateMap = {
|
|
474
|
+
CHANGES_REQUESTED: "changes-requested",
|
|
475
|
+
APPROVED: "approved",
|
|
476
|
+
COMMENTED: "commented",
|
|
477
|
+
DISMISSED: "dismissed"
|
|
478
|
+
};
|
|
479
|
+
const yourReview = stateMap[latestState] ?? latestState.toLowerCase();
|
|
480
|
+
const yourReviewAge = latestTime ? timeAgo(latestTime, now) : "unknown";
|
|
481
|
+
return { yourReview, yourReviewAge };
|
|
482
|
+
}
|
|
483
|
+
function latestCommitAge(pr, now) {
|
|
484
|
+
const commits = pr.commits ?? [];
|
|
485
|
+
if (commits.length === 0) return void 0;
|
|
486
|
+
let latest = commits[0].committedDate;
|
|
487
|
+
for (let i = 1; i < commits.length; i++) {
|
|
488
|
+
if (commits[i].committedDate > latest) latest = commits[i].committedDate;
|
|
449
489
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
490
|
+
return timeAgo(latest, now);
|
|
491
|
+
}
|
|
492
|
+
function latestCommentAge(item, now) {
|
|
493
|
+
if (item.comments.length === 0) return void 0;
|
|
494
|
+
let latest = item.comments[0].createdAt;
|
|
495
|
+
for (let i = 1; i < item.comments.length; i++) {
|
|
496
|
+
if (item.comments[i].createdAt > latest) latest = item.comments[i].createdAt;
|
|
458
497
|
}
|
|
459
|
-
return
|
|
498
|
+
return timeAgo(latest, now);
|
|
460
499
|
}
|
|
461
500
|
|
|
462
501
|
// src/summary/builder.ts
|
|
@@ -485,7 +524,9 @@ function classifyIssue(issue, now) {
|
|
|
485
524
|
tags,
|
|
486
525
|
author,
|
|
487
526
|
comments,
|
|
488
|
-
age
|
|
527
|
+
age,
|
|
528
|
+
lastComment: latestCommentAge(issue, now),
|
|
529
|
+
updated: timeAgo(issue.updatedAt, now)
|
|
489
530
|
};
|
|
490
531
|
if (hasExactLabel(issue.labels, "needs:human")) {
|
|
491
532
|
return {
|
|
@@ -529,13 +570,13 @@ function classifyPR(pr, now) {
|
|
|
529
570
|
let status2;
|
|
530
571
|
if (pr.isDraft) status2 = "draft";
|
|
531
572
|
else if (pr.reviewDecision === "CHANGES_REQUESTED" || changesRequestedCount(pr) > 0) status2 = "changes-requested";
|
|
532
|
-
else status2 = "
|
|
573
|
+
else status2 = "pending";
|
|
533
574
|
return {
|
|
534
575
|
bucket: "addressFeedback",
|
|
535
576
|
item: { number: pr.number, title: pr.title, tags, author, comments, age, status: status2, checks, mergeable: merge, review }
|
|
536
577
|
};
|
|
537
578
|
}
|
|
538
|
-
const status = pr.reviewDecision === "APPROVED" ? "approved" : "
|
|
579
|
+
const status = pr.reviewDecision === "APPROVED" ? "approved" : "pending";
|
|
539
580
|
return {
|
|
540
581
|
bucket: "reviewPRs",
|
|
541
582
|
item: { number: pr.number, title: pr.title, tags, author, comments, age, status, checks, mergeable: merge, review }
|
|
@@ -553,6 +594,7 @@ function buildCompetitionMap(prs, currentUser) {
|
|
|
553
594
|
return map;
|
|
554
595
|
}
|
|
555
596
|
function buildSummary(repo, issues, prs, currentUser, now = /* @__PURE__ */ new Date()) {
|
|
597
|
+
const needsHuman = [];
|
|
556
598
|
const voteOn = [];
|
|
557
599
|
const discuss = [];
|
|
558
600
|
const implement = [];
|
|
@@ -560,7 +602,8 @@ function buildSummary(repo, issues, prs, currentUser, now = /* @__PURE__ */ new
|
|
|
560
602
|
const addressFeedback = [];
|
|
561
603
|
for (const issue of issues) {
|
|
562
604
|
const { bucket, item } = classifyIssue(issue, now);
|
|
563
|
-
if (bucket === "
|
|
605
|
+
if (bucket === "needsHuman") needsHuman.push(item);
|
|
606
|
+
else if (bucket === "voteOn") voteOn.push(item);
|
|
564
607
|
else if (bucket === "discuss") discuss.push(item);
|
|
565
608
|
else if (bucket === "implement") implement.push(item);
|
|
566
609
|
}
|
|
@@ -573,10 +616,17 @@ function buildSummary(repo, issues, prs, currentUser, now = /* @__PURE__ */ new
|
|
|
573
616
|
}
|
|
574
617
|
for (const pr of prs) {
|
|
575
618
|
const { bucket, item } = classifyPR(pr, now);
|
|
619
|
+
const ctx = reviewContext(pr, currentUser, now);
|
|
620
|
+
if (ctx) {
|
|
621
|
+
item.yourReview = ctx.yourReview;
|
|
622
|
+
item.yourReviewAge = ctx.yourReviewAge;
|
|
623
|
+
}
|
|
624
|
+
item.lastCommit = latestCommitAge(pr, now);
|
|
625
|
+
item.lastComment = latestCommentAge(pr, now);
|
|
626
|
+
item.updated = timeAgo(pr.updatedAt, now);
|
|
576
627
|
if (bucket === "reviewPRs") reviewPRs.push(item);
|
|
577
628
|
else addressFeedback.push(item);
|
|
578
629
|
}
|
|
579
|
-
const alerts = generateAlerts(issues, prs, now);
|
|
580
630
|
const driveDiscussion = [];
|
|
581
631
|
const driveImplementation = [];
|
|
582
632
|
const filteredDiscuss = discuss.filter((item) => {
|
|
@@ -610,6 +660,7 @@ function buildSummary(repo, issues, prs, currentUser, now = /* @__PURE__ */ new
|
|
|
610
660
|
return {
|
|
611
661
|
repo,
|
|
612
662
|
currentUser,
|
|
663
|
+
needsHuman,
|
|
613
664
|
driveDiscussion,
|
|
614
665
|
driveImplementation,
|
|
615
666
|
voteOn: filteredVoteOn,
|
|
@@ -617,7 +668,6 @@ function buildSummary(repo, issues, prs, currentUser, now = /* @__PURE__ */ new
|
|
|
617
668
|
implement,
|
|
618
669
|
reviewPRs: filteredReviewPRs,
|
|
619
670
|
addressFeedback: filteredAddressFeedback,
|
|
620
|
-
alerts,
|
|
621
671
|
notes: []
|
|
622
672
|
};
|
|
623
673
|
}
|
|
@@ -641,21 +691,45 @@ function formatMeta(item, sectionType, currentUser) {
|
|
|
641
691
|
const isYou = item.author === currentUser;
|
|
642
692
|
const authorVal = isYou ? chalk.green(`${item.author} (you)`) : chalk.dim(item.author);
|
|
643
693
|
const parts = [`by: ${authorVal}`];
|
|
644
|
-
if (sectionType === "implement") {
|
|
694
|
+
if (sectionType === "implement" || sectionType === "needsHuman") {
|
|
645
695
|
parts.push(kv("assigned", item.assigned ?? "--"));
|
|
646
696
|
parts.push(kv("comments", item.comments));
|
|
697
|
+
if (item.lastComment) parts.push(kv("last-comment", item.lastComment));
|
|
698
|
+
if (item.updated) parts.push(kv("updated", item.updated));
|
|
647
699
|
parts.push(kv("created", item.age));
|
|
648
700
|
if (item.competingPRs !== void 0) {
|
|
649
701
|
parts.push(kv("competing", item.competingPRs));
|
|
650
702
|
}
|
|
651
703
|
} else if (sectionType === "vote" || sectionType === "discuss" || sectionType === "driveDiscussion") {
|
|
652
704
|
parts.push(kv("comments", item.comments));
|
|
705
|
+
if (item.lastComment) parts.push(kv("last-comment", item.lastComment));
|
|
706
|
+
if (item.updated) parts.push(kv("updated", item.updated));
|
|
653
707
|
parts.push(kv("created", item.age));
|
|
654
708
|
} else {
|
|
655
|
-
if (item.status !== void 0)
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
709
|
+
if (item.status !== void 0) {
|
|
710
|
+
const statusVal = /changes.requested/i.test(item.status) ? chalk.red(item.status) : chalk.dim(item.status);
|
|
711
|
+
parts.push(`status: ${statusVal}`);
|
|
712
|
+
}
|
|
713
|
+
if (item.checks !== void 0 && item.checks !== null) {
|
|
714
|
+
const checksVal = /fail/i.test(item.checks) ? chalk.red(item.checks) : chalk.dim(item.checks);
|
|
715
|
+
parts.push(`checks: ${checksVal}`);
|
|
716
|
+
}
|
|
717
|
+
if (item.mergeable !== void 0 && item.mergeable !== null) {
|
|
718
|
+
const mergeVal = /conflict/i.test(item.mergeable) ? chalk.red(item.mergeable) : chalk.dim(item.mergeable);
|
|
719
|
+
parts.push(`merge: ${mergeVal}`);
|
|
720
|
+
}
|
|
721
|
+
if (item.review) {
|
|
722
|
+
const segments = [`${item.review.approvals} approved`];
|
|
723
|
+
if (item.review.changesRequested > 0) segments.push(chalk.red(`${item.review.changesRequested} changes-requested`));
|
|
724
|
+
parts.push(kv("review", segments.join(", ")));
|
|
725
|
+
}
|
|
726
|
+
if (item.yourReview) {
|
|
727
|
+
const age = item.yourReviewAge ? ` (${item.yourReviewAge})` : "";
|
|
728
|
+
parts.push(kv("you", `${item.yourReview}${age}`));
|
|
729
|
+
}
|
|
730
|
+
if (item.lastCommit) parts.push(kv("last-commit", item.lastCommit));
|
|
731
|
+
if (item.lastComment) parts.push(kv("last-comment", item.lastComment));
|
|
732
|
+
if (item.updated) parts.push(kv("updated", item.updated));
|
|
659
733
|
parts.push(kv("comments", item.comments));
|
|
660
734
|
parts.push(kv("created", item.age));
|
|
661
735
|
}
|
|
@@ -666,7 +740,9 @@ function formatItem(item, currentUser, sectionType) {
|
|
|
666
740
|
const prefix = isYou ? chalk.green("\u2605") : " ";
|
|
667
741
|
const num = chalk.cyan(`#${item.number}`);
|
|
668
742
|
const tags = formatTags(item.tags);
|
|
669
|
-
const
|
|
743
|
+
const hasProblems = item.checks && /fail/i.test(item.checks) || item.mergeable && /conflict/i.test(item.mergeable);
|
|
744
|
+
const warningIcon = hasProblems ? " " + chalk.red("\u2717") : "";
|
|
745
|
+
const titleLine = `${prefix} ${num} ${item.title}${tags}${warningIcon}`;
|
|
670
746
|
const metaLine = ` ${formatMeta(item, sectionType, currentUser)}`;
|
|
671
747
|
return `${titleLine}
|
|
672
748
|
${metaLine}`;
|
|
@@ -685,15 +761,9 @@ function formatSection(title, items, currentUser, sectionType, limit) {
|
|
|
685
761
|
function formatSummaryBody(summary, limit) {
|
|
686
762
|
const u = summary.currentUser;
|
|
687
763
|
const sections = [];
|
|
688
|
-
if (summary.alerts.length > 0) {
|
|
689
|
-
const alertLines = [
|
|
690
|
-
sectionDivider("REQUIRES YOUR ATTENTION", summary.alerts.length),
|
|
691
|
-
...summary.alerts.map((a) => ` ${a.icon} ${chalk.yellow(a.message)}`)
|
|
692
|
-
];
|
|
693
|
-
sections.push(alertLines.join("\n"));
|
|
694
|
-
}
|
|
695
764
|
sections.push(
|
|
696
765
|
...[
|
|
766
|
+
formatSection("NEEDS HUMAN", summary.needsHuman, u, "needsHuman", limit),
|
|
697
767
|
formatSection("DRIVE THE DISCUSSION", summary.driveDiscussion, u, "driveDiscussion", limit),
|
|
698
768
|
formatSection("DRIVE THE IMPLEMENTATION", summary.driveImplementation, u, "driveImplementation", limit),
|
|
699
769
|
formatSection("VOTE ON ISSUES", summary.voteOn, u, "vote", limit),
|
|
@@ -767,7 +837,7 @@ function jsonBuzz(roleName, role, summary) {
|
|
|
767
837
|
implement: summary.implement,
|
|
768
838
|
reviewPRs: summary.reviewPRs,
|
|
769
839
|
addressFeedback: summary.addressFeedback,
|
|
770
|
-
|
|
840
|
+
needsHuman: summary.needsHuman,
|
|
771
841
|
notes: summary.notes
|
|
772
842
|
}
|
|
773
843
|
},
|
|
@@ -787,7 +857,7 @@ function jsonStatus(summary) {
|
|
|
787
857
|
implement: summary.implement,
|
|
788
858
|
reviewPRs: summary.reviewPRs,
|
|
789
859
|
addressFeedback: summary.addressFeedback,
|
|
790
|
-
|
|
860
|
+
needsHuman: summary.needsHuman,
|
|
791
861
|
notes: summary.notes
|
|
792
862
|
},
|
|
793
863
|
null,
|
|
@@ -938,7 +1008,7 @@ function parseLimit(value) {
|
|
|
938
1008
|
var program = new Command();
|
|
939
1009
|
program.name("hivemoot").description("CLI for Hivemoot agents \u2014 role instructions and repo work summaries").version(version).option("--github-token <token>", "GitHub personal access token (or set GITHUB_TOKEN env var)");
|
|
940
1010
|
program.hook("preAction", () => {
|
|
941
|
-
const token = program.opts().githubToken;
|
|
1011
|
+
const token = program.opts().githubToken ?? process.env.GITHUB_TOKEN;
|
|
942
1012
|
if (token) {
|
|
943
1013
|
setGhToken(token);
|
|
944
1014
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config/types.ts","../src/config/loader.ts","../src/github/client.ts","../src/github/repo.ts","../src/github/issues.ts","../src/github/pulls.ts","../src/github/user.ts","../src/summary/utils.ts","../src/summary/alerts.ts","../src/summary/builder.ts","../src/output/formatter.ts","../src/output/json.ts","../src/commands/buzz.ts","../src/commands/roles.ts","../src/commands/init.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { Command, InvalidArgumentError } from \"commander\";\nimport { buzzCommand } from \"./commands/buzz.js\";\nimport { rolesCommand } from \"./commands/roles.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { CliError } from \"./config/types.js\";\nimport { setGhToken } from \"./github/client.js\";\n\nconst require = createRequire(import.meta.url);\nconst { version } = require(\"../package.json\") as { version: string };\n\nfunction parseLimit(value: string): number {\n const n = parseInt(value, 10);\n if (isNaN(n) || n <= 0) {\n throw new InvalidArgumentError(\"Must be a positive integer.\");\n }\n return n;\n}\n\nconst program = new Command();\n\nprogram\n .name(\"hivemoot\")\n .description(\"CLI for Hivemoot agents — role instructions and repo work summaries\")\n .version(version)\n .option(\"--github-token <token>\", \"GitHub personal access token (or set GITHUB_TOKEN env var)\");\n\nprogram.hook(\"preAction\", () => {\n const token = program.opts().githubToken as string | undefined;\n if (token) {\n setGhToken(token);\n }\n});\n\nprogram\n .command(\"buzz\")\n .description(\"Get role instructions and repo work summary (omit --role for summary only)\")\n .option(\"--role <role>\", \"Role to assume (e.g. engineer, tech_lead)\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--limit <n>\", \"Max items per section\", parseLimit)\n .option(\"--fetch-limit <n>\", \"Max issues/PRs to fetch from GitHub (default: 200)\", parseLimit)\n .option(\"--repo <owner/repo>\", \"Target repository (default: detect from git)\")\n .action(buzzCommand);\n\nprogram\n .command(\"roles\")\n .description(\"List available roles from team config\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--repo <owner/repo>\", \"Target repository (default: detect from git)\")\n .action(rolesCommand);\n\nprogram\n .command(\"init\")\n .description(\"Print a sample .github/hivemoot.yml template\")\n .action(initCommand);\n\n// Global error handler\nprogram.exitOverride();\n\ntry {\n await program.parseAsync(process.argv);\n} catch (err) {\n if (err instanceof CliError) {\n // Check if parent command requested --json output\n const isJson = process.argv.includes(\"--json\");\n if (isJson) {\n console.log(JSON.stringify({ error: { code: err.code, message: err.message } }, null, 2));\n } else {\n console.error(`Error: ${err.message}`);\n }\n process.exit(err.exitCode);\n }\n\n // Commander exits for --help, --version, etc.\n if (err instanceof Error && \"exitCode\" in err) {\n const exitCode = (err as Error & { exitCode: number }).exitCode;\n process.exit(exitCode);\n }\n\n console.error(\"Unexpected error:\", err);\n process.exit(1);\n}\n","// ── YAML Config Types ──────────────────────────────────────────────\n\nexport interface RoleConfig {\n description: string;\n instructions: string;\n}\n\nexport interface TeamConfig {\n name?: string;\n roles: Record<string, RoleConfig>;\n}\n\nexport interface HivemootConfig {\n version?: number;\n governance?: unknown;\n team?: TeamConfig;\n}\n\n// ── GitHub Data Types ──────────────────────────────────────────────\n\nexport interface GitHubIssue {\n number: number;\n title: string;\n labels: Array<{ name: string }>;\n assignees: Array<{ login: string }>;\n author: { login: string } | null;\n comments: Array<{ createdAt: string }>;\n createdAt: string;\n updatedAt: string;\n url: string;\n}\n\nexport interface StatusCheck {\n context: string;\n state: string | undefined;\n conclusion: string | null;\n}\n\nexport interface PRReview {\n state: string;\n author: { login: string } | null;\n}\n\nexport interface GitHubPR {\n number: number;\n title: string;\n state: string;\n author: { login: string } | null;\n labels: Array<{ name: string }>;\n comments: Array<{ createdAt: string }>;\n reviews: PRReview[];\n createdAt: string;\n updatedAt: string;\n url: string;\n isDraft: boolean;\n reviewDecision: string;\n mergeable: string;\n statusCheckRollup: StatusCheck[] | null;\n closingIssuesReferences: Array<{ number: number }>;\n}\n\n// ── Repo Identity ──────────────────────────────────────────────────\n\nexport interface RepoRef {\n owner: string;\n repo: string;\n}\n\n// ── Summary Types ──────────────────────────────────────────────────\n\nexport interface ReviewSummary {\n approvals: number;\n changesRequested: number;\n}\n\nexport interface SummaryItem {\n number: number;\n title: string;\n tags: string[];\n author: string;\n // Common fields\n comments: number;\n age: string; // \"just now\" | \"5 minutes ago\" | \"2 hours ago\" | \"3 days ago\"\n // Issue-specific\n assigned?: string; // comma-separated logins, or undefined (= unassigned)\n competingPRs?: number; // only on implement items with competing PRs\n // PR-specific\n status?: string; // \"waiting\" | \"approved\" | \"changes-requested\" | \"draft\"\n checks?: string | null; // \"passing\" | \"failing\" | \"pending\" | null\n mergeable?: string | null; // \"clean\" | \"conflicts\" | null\n review?: ReviewSummary;\n}\n\nexport interface Alert {\n icon: string;\n message: string;\n}\n\nexport interface RepoSummary {\n repo: RepoRef;\n currentUser: string;\n driveDiscussion: SummaryItem[];\n driveImplementation: SummaryItem[];\n voteOn: SummaryItem[];\n discuss: SummaryItem[];\n implement: SummaryItem[];\n reviewPRs: SummaryItem[];\n addressFeedback: SummaryItem[];\n alerts: Alert[];\n notes: string[];\n}\n\n// ── CLI Options ────────────────────────────────────────────────────\n\nexport interface BuzzOptions {\n role?: string;\n json?: boolean;\n limit?: number;\n fetchLimit?: number;\n repo?: string;\n}\n\nexport interface RolesOptions {\n json?: boolean;\n repo?: string;\n}\n\n// ── Error Types ────────────────────────────────────────────────────\n\nexport type ErrorCode =\n | \"GH_NOT_FOUND\"\n | \"GH_NOT_AUTHENTICATED\"\n | \"NOT_GIT_REPO\"\n | \"CONFIG_NOT_FOUND\"\n | \"NO_TEAM_CONFIG\"\n | \"ROLE_NOT_FOUND\"\n | \"INVALID_CONFIG\"\n | \"RATE_LIMITED\"\n | \"GH_ERROR\";\n\nexport class CliError extends Error {\n constructor(\n message: string,\n public readonly code: ErrorCode,\n public readonly exitCode: number = 1,\n ) {\n super(message);\n this.name = \"CliError\";\n }\n}\n","import yaml from \"js-yaml\";\nimport { gh } from \"../github/client.js\";\nimport type { HivemootConfig, TeamConfig, RepoRef, RoleConfig } from \"./types.js\";\nimport { CliError } from \"./types.js\";\n\nconst ROLE_SLUG_RE = /^[a-z][a-z0-9_]{0,49}$/;\nconst MAX_DESCRIPTION_LENGTH = 500;\nconst MAX_INSTRUCTIONS_LENGTH = 10_000;\n\nfunction validateTeamConfig(raw: HivemootConfig): TeamConfig {\n if (!raw.team) {\n throw new CliError(\n \"No team config in .github/hivemoot.yml. Run: hivemoot init\",\n \"NO_TEAM_CONFIG\",\n 1,\n );\n }\n\n const { team } = raw;\n\n if (!team.roles || typeof team.roles !== \"object\" || Object.keys(team.roles).length === 0) {\n throw new CliError(\n \"Config error: team.roles must contain at least one role\",\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n const validatedRoles: Record<string, RoleConfig> = {};\n\n for (const [slug, role] of Object.entries(team.roles)) {\n if (!ROLE_SLUG_RE.test(slug)) {\n throw new CliError(\n `Config error: invalid role slug \"${slug}\" — must match /^[a-z][a-z0-9_]{0,49}$/`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (typeof role !== \"object\" || role === null) {\n throw new CliError(\n `Config error: role \"${slug}\" must be an object`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n const r = role as unknown as Record<string, unknown>;\n\n if (typeof r.description !== \"string\" || r.description.length === 0) {\n throw new CliError(\n `Config error: role \"${slug}\" is missing a description`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (r.description.length > MAX_DESCRIPTION_LENGTH) {\n throw new CliError(\n `Config error: role \"${slug}\" description exceeds ${MAX_DESCRIPTION_LENGTH} characters`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (typeof r.instructions !== \"string\" || r.instructions.length === 0) {\n throw new CliError(\n `Config error: role \"${slug}\" is missing instructions`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (r.instructions.length > MAX_INSTRUCTIONS_LENGTH) {\n throw new CliError(\n `Config error: role \"${slug}\" instructions exceeds ${MAX_INSTRUCTIONS_LENGTH} characters`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n validatedRoles[slug] = {\n description: r.description,\n instructions: r.instructions,\n };\n }\n\n return {\n name: typeof team.name === \"string\" ? team.name : undefined,\n roles: validatedRoles,\n };\n}\n\nexport async function loadTeamConfig(repo: RepoRef): Promise<TeamConfig> {\n let rawJson: string;\n\n try {\n rawJson = await gh([\n \"api\",\n `repos/${repo.owner}/${repo.repo}/contents/.github/hivemoot.yml`,\n ]);\n } catch (err) {\n if (err instanceof Error && /404|Not Found/i.test(err.message)) {\n throw new CliError(\n \"No .github/hivemoot.yml found. Run: hivemoot init\",\n \"CONFIG_NOT_FOUND\",\n 1,\n );\n }\n throw err;\n }\n\n let content: string;\n try {\n const parsed = JSON.parse(rawJson);\n content = Buffer.from(parsed.content, \"base64\").toString(\"utf-8\");\n } catch (err) {\n const detail = err instanceof Error ? `: ${err.message}` : \"\";\n throw new CliError(\n `Config error: failed to decode .github/hivemoot.yml content${detail}`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n let config: HivemootConfig;\n try {\n config = yaml.load(content, { schema: yaml.JSON_SCHEMA }) as HivemootConfig;\n } catch (err) {\n const detail = err instanceof Error ? `: ${err.message}` : \"\";\n throw new CliError(\n `Config error: invalid YAML in .github/hivemoot.yml${detail}`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (typeof config !== \"object\" || config === null) {\n throw new CliError(\n \"Config error: .github/hivemoot.yml must be a YAML object\",\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n return validateTeamConfig(config);\n}\n","import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { CliError } from \"../config/types.js\";\n\nconst execFileAsync = promisify(execFile);\n\nlet ghToken: string | undefined;\n\n/** Set the GitHub token used for all subsequent `gh` calls. */\nexport function setGhToken(token: string): void {\n ghToken = token;\n}\n\n/**\n * Execute a `gh` CLI command and return stdout.\n * All GitHub I/O goes through this single function.\n */\nexport async function gh(args: string[]): Promise<string> {\n try {\n const opts: { timeout: number; env?: NodeJS.ProcessEnv } = {\n timeout: 30_000,\n };\n if (ghToken) {\n opts.env = { ...process.env, GH_TOKEN: ghToken };\n }\n const { stdout } = await execFileAsync(\"gh\", args, opts);\n return stdout.trim();\n } catch (err: unknown) {\n const error = err as NodeJS.ErrnoException & {\n stderr?: string;\n code?: string | number;\n };\n\n if (error.code === \"ENOENT\") {\n throw new CliError(\n \"gh CLI not found. Install: https://cli.github.com\",\n \"GH_NOT_FOUND\",\n 2,\n );\n }\n\n const stderr = error.stderr ?? error.message ?? \"\";\n\n if (/gh auth login|not logged in|authentication required/i.test(stderr)) {\n throw new CliError(\n \"Not authenticated. Pass --github-token <token>, set GITHUB_TOKEN, or run: gh auth login\",\n \"GH_NOT_AUTHENTICATED\",\n 2,\n );\n }\n\n if (/rate.?limit|API rate limit/i.test(stderr)) {\n throw new CliError(\n \"GitHub rate limited. Try again later.\",\n \"RATE_LIMITED\",\n 3,\n );\n }\n\n throw new CliError(stderr || \"gh command failed\", \"GH_ERROR\", 1);\n }\n}\n","import { CliError, type RepoRef } from \"../config/types.js\";\nimport { gh } from \"./client.js\";\n\nconst GITHUB_NAME_RE = /^[a-zA-Z0-9._-]+$/;\n\nexport async function resolveRepo(repoFlag?: string): Promise<RepoRef> {\n if (repoFlag) {\n const parts = repoFlag.split(\"/\");\n if (parts.length !== 2 || !parts[0] || !parts[1]) {\n throw new CliError(\n `Invalid repo format: \"${repoFlag}\". Expected OWNER/REPO`,\n \"GH_ERROR\",\n 1,\n );\n }\n if (!GITHUB_NAME_RE.test(parts[0]) || !GITHUB_NAME_RE.test(parts[1])) {\n throw new CliError(\n `Invalid repo name: \"${repoFlag}\". Owner and repo must match ${GITHUB_NAME_RE}`,\n \"GH_ERROR\",\n 1,\n );\n }\n return { owner: parts[0], repo: parts[1] };\n }\n\n try {\n const json = await gh([\"repo\", \"view\", \"--json\", \"owner,name\"]);\n let data: { owner?: { login?: string } | string; name?: string };\n try {\n data = JSON.parse(json);\n } catch {\n throw new CliError(\n \"Failed to parse repo info from gh CLI. Use --repo OWNER/REPO\",\n \"GH_ERROR\",\n 1,\n );\n }\n // gh returns owner as an object { login: \"...\" } not a plain string\n const owner =\n typeof data.owner === \"object\" && data.owner !== null\n ? data.owner.login\n : data.owner;\n const name = data.name;\n if (typeof owner !== \"string\" || !owner || typeof name !== \"string\" || !name) {\n throw new CliError(\n \"Could not detect repo owner/name. Use --repo OWNER/REPO\",\n \"NOT_GIT_REPO\",\n 2,\n );\n }\n return { owner, repo: name };\n } catch (err) {\n if (err instanceof CliError) {\n throw err;\n }\n throw new CliError(\n \"Not in a git repository. Use --repo OWNER/REPO\",\n \"NOT_GIT_REPO\",\n 2,\n );\n }\n}\n","import type { GitHubIssue, RepoRef } from \"../config/types.js\";\nimport { CliError } from \"../config/types.js\";\nimport { gh } from \"./client.js\";\n\nexport async function fetchIssues(repo: RepoRef, limit = 200): Promise<GitHubIssue[]> {\n const json = await gh([\n \"issue\",\n \"list\",\n \"-R\",\n `${repo.owner}/${repo.repo}`,\n \"--state\",\n \"open\",\n \"--json\",\n \"number,title,labels,assignees,author,comments,createdAt,updatedAt,url\",\n \"--limit\",\n String(limit),\n ]);\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n throw new CliError(\n \"Failed to parse issues response from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n if (!Array.isArray(parsed)) {\n throw new CliError(\n \"Unexpected issues response format from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n return parsed as GitHubIssue[];\n}\n","import type { GitHubPR, RepoRef } from \"../config/types.js\";\nimport { CliError } from \"../config/types.js\";\nimport { gh } from \"./client.js\";\n\nexport async function fetchPulls(repo: RepoRef, limit = 200): Promise<GitHubPR[]> {\n const json = await gh([\n \"pr\",\n \"list\",\n \"-R\",\n `${repo.owner}/${repo.repo}`,\n \"--state\",\n \"open\",\n \"--json\",\n \"number,title,state,author,labels,comments,reviews,createdAt,updatedAt,url,isDraft,reviewDecision,mergeable,statusCheckRollup,closingIssuesReferences\",\n \"--limit\",\n String(limit),\n ]);\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n throw new CliError(\n \"Failed to parse pull requests response from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n if (!Array.isArray(parsed)) {\n throw new CliError(\n \"Unexpected pull requests response format from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n return parsed as GitHubPR[];\n}\n","import { gh } from \"./client.js\";\nimport { CliError } from \"../config/types.js\";\n\n/**\n * Return the login of the currently authenticated GitHub user.\n */\nexport async function fetchCurrentUser(): Promise<string> {\n const login = await gh([\"api\", \"user\", \"--jq\", \".login\"]);\n if (!login) {\n throw new CliError(\n \"Could not determine GitHub username. Pass --github-token <token>, set GITHUB_TOKEN, or run: gh auth login\",\n \"GH_NOT_AUTHENTICATED\",\n 2,\n );\n }\n return login;\n}\n","import type { GitHubPR } from \"../config/types.js\";\n\nexport function hasLabel(labels: Array<{ name: string }>, keyword: string): boolean {\n return labels.some((l) =>\n l.name.toLowerCase().split(/[:\\-_]/).some((seg) => seg === keyword),\n );\n}\n\nexport function hasExactLabel(labels: Array<{ name: string }>, labelName: string): boolean {\n return labels.some((l) => l.name.toLowerCase() === labelName.toLowerCase());\n}\n\n/** Human-relative time string (\"just now\", \"5 minutes ago\", \"yesterday\", etc.). */\nexport function timeAgo(dateStr: string, now: Date): string {\n const ms = now.getTime() - new Date(dateStr).getTime();\n if (ms < 0) return \"just now\"; // future date — clock skew or bad data\n\n const minutes = Math.floor(ms / 60_000);\n const hours = Math.floor(ms / 3_600_000);\n const days = Math.floor(ms / 86_400_000);\n\n if (minutes < 1) return \"just now\";\n if (minutes === 1) return \"1 minute ago\";\n if (minutes < 60) return `${minutes} minutes ago`;\n if (hours === 1) return \"1 hour ago\";\n if (hours < 24) return `${hours} hours ago`;\n if (days === 1) return \"yesterday\";\n if (days < 7) return `${days} days ago`;\n if (days < 14) return \"1 week ago\";\n if (days < 30) return `${Math.floor(days / 7)} weeks ago`;\n if (days < 60) return \"1 month ago\";\n if (days < 365) return `${Math.floor(days / 30)} months ago`;\n const years = Math.floor(days / 365);\n if (years === 1) return \"1 year ago\";\n return `${years} years ago`;\n}\n\nexport function daysSince(dateStr: string, now: Date): number {\n const diff = now.getTime() - new Date(dateStr).getTime();\n return Math.max(0, Math.floor(diff / (1000 * 60 * 60 * 24)));\n}\n\nexport function hasCIFailure(pr: GitHubPR): boolean {\n if (!pr.statusCheckRollup) return false;\n return pr.statusCheckRollup.some((check) => {\n const conclusion = check.conclusion?.toUpperCase();\n const state = check.state?.toUpperCase();\n return conclusion === \"FAILURE\" || state === \"FAILURE\";\n });\n}\n\n/**\n * Summarize all status checks into a single label.\n * Returns null when there are no checks to report.\n */\nexport function checkStatus(pr: GitHubPR): string | null {\n if (!pr.statusCheckRollup || pr.statusCheckRollup.length === 0) return null;\n\n const hasFailing = hasCIFailure(pr);\n if (hasFailing) return \"checks failing\";\n\n const hasPending = pr.statusCheckRollup.some((c) => {\n const s = c.state?.toUpperCase();\n return s === \"PENDING\" || s === \"QUEUED\" || s === \"IN_PROGRESS\";\n });\n if (hasPending) return \"checks pending\";\n\n return \"checks passing\";\n}\n\n/**\n * Return a merge-conflict label, or null if no conflict info.\n */\nexport function mergeStatus(pr: GitHubPR): string | null {\n if (pr.mergeable === \"CONFLICTING\") return \"has conflicts\";\n if (pr.mergeable === \"MERGEABLE\") return \"no conflicts\";\n return null;\n}\n\n/** Collapse reviews to the latest state per author. */\nfunction latestReviewByAuthor(pr: GitHubPR): Map<string, string> {\n const map = new Map<string, string>();\n for (const review of pr.reviews ?? []) {\n map.set(review.author?.login ?? \"ghost\", review.state);\n }\n return map;\n}\n\n/** Count unique approvals (latest review per author). */\nexport function approvalCount(pr: GitHubPR): number {\n let count = 0;\n for (const state of latestReviewByAuthor(pr).values()) {\n if (state === \"APPROVED\") count++;\n }\n return count;\n}\n\n/**\n * Count unique changes-requested reviews (latest review per author).\n * If an author requests changes then later approves, they are no longer counted.\n */\nexport function changesRequestedCount(pr: GitHubPR): number {\n let count = 0;\n for (const state of latestReviewByAuthor(pr).values()) {\n if (state === \"CHANGES_REQUESTED\") count++;\n }\n return count;\n}\n","import type { GitHubIssue, GitHubPR, Alert } from \"../config/types.js\";\nimport { hasLabel, hasExactLabel, daysSince, hasCIFailure } from \"./utils.js\";\n\nconst STALE_DISCUSSION_DAYS = 3;\nconst PR_WAITING_REVIEW_DAYS = 2;\n\nfunction lastCommentDate(issue: GitHubIssue): string | null {\n if (issue.comments.length === 0) return null;\n return issue.comments.reduce((latest, c) =>\n c.createdAt > latest.createdAt ? c : latest,\n ).createdAt;\n}\n\nexport function generateAlerts(\n issues: GitHubIssue[],\n prs: GitHubPR[],\n now: Date = new Date(),\n): Alert[] {\n const alerts: Alert[] = [];\n\n // Stale discussions: discuss-labeled issues with no recent comments\n for (const issue of issues) {\n if (!hasLabel(issue.labels, \"discuss\") && !hasExactLabel(issue.labels, \"phase:discussion\")) continue;\n const lastComment = lastCommentDate(issue);\n const referenceDate = lastComment ?? issue.createdAt;\n const days = daysSince(referenceDate, now);\n if (days >= STALE_DISCUSSION_DAYS) {\n alerts.push({\n icon: \"\\u26a0\\ufe0f\",\n message: `#${issue.number} in discussion ${days} days, no recent comments`,\n });\n }\n }\n\n // Issues needing human attention\n for (const issue of issues) {\n if (hasExactLabel(issue.labels, \"needs:human\")) {\n alerts.push({\n icon: \"\\ud83d\\uded1\",\n message: `#${issue.number} needs human attention`,\n });\n }\n }\n\n // Only PRs in the governance intake (with \"implementation\" label) generate attention items\n const intakePRs = prs.filter((pr) => hasExactLabel(pr.labels, \"implementation\"));\n\n // PRs waiting on review too long (skip approved/changes-requested/drafts)\n for (const pr of intakePRs) {\n if (pr.isDraft) continue;\n if (pr.reviewDecision === \"APPROVED\" || pr.reviewDecision === \"CHANGES_REQUESTED\") continue;\n const days = daysSince(pr.createdAt, now);\n if (days >= PR_WAITING_REVIEW_DAYS) {\n alerts.push({\n icon: \"\\u26a0\\ufe0f\",\n message: `PR #${pr.number} waiting on review ${days} days`,\n });\n }\n }\n\n // CI failures on non-draft PRs\n for (const pr of intakePRs) {\n if (pr.isDraft) continue;\n if (hasCIFailure(pr)) {\n alerts.push({\n icon: \"\\u26a0\\ufe0f\",\n message: `PR #${pr.number} has CI failures`,\n });\n }\n }\n\n return alerts;\n}\n","import type {\n GitHubIssue,\n GitHubPR,\n RepoRef,\n RepoSummary,\n SummaryItem,\n} from \"../config/types.js\";\nimport { generateAlerts } from \"./alerts.js\";\nimport { hasLabel, hasExactLabel, hasCIFailure, checkStatus, mergeStatus, approvalCount, changesRequestedCount, timeAgo } from \"./utils.js\";\n\n/** Map verbose check labels to compact values for structured output. */\nfunction compactChecks(raw: string | null): string | null {\n if (raw === null) return null;\n if (raw === \"checks failing\") return \"failing\";\n if (raw === \"checks pending\") return \"pending\";\n if (raw === \"checks passing\") return \"passing\";\n return raw;\n}\n\n/** Map verbose merge labels to compact values for structured output. */\nfunction compactMergeable(raw: string | null): string | null {\n if (raw === null) return null;\n if (raw === \"has conflicts\") return \"conflicts\";\n if (raw === \"no conflicts\") return \"clean\";\n return raw;\n}\n\nfunction classifyIssue(\n issue: GitHubIssue,\n now: Date,\n): { bucket: \"voteOn\" | \"discuss\" | \"implement\" | \"needsHuman\"; item: SummaryItem } {\n const age = timeAgo(issue.createdAt, now);\n const assigned =\n issue.assignees.length > 0\n ? issue.assignees.map((a) => a.login).join(\", \")\n : undefined;\n\n const tags = issue.labels.map((l) => l.name);\n const author = issue.author?.login ?? \"ghost\";\n const comments = issue.comments.length;\n\n const base: SummaryItem = {\n number: issue.number,\n title: issue.title,\n tags,\n author,\n comments,\n age,\n };\n\n // Issues needing human attention are excluded from all actionable buckets\n if (hasExactLabel(issue.labels, \"needs:human\")) {\n return {\n bucket: \"needsHuman\",\n item: { ...base, assigned },\n };\n }\n\n // Bot governance labels (exact match)\n if (hasExactLabel(issue.labels, \"phase:voting\") || hasExactLabel(issue.labels, \"phase:extended-voting\")) {\n return { bucket: \"voteOn\", item: base };\n }\n if (hasExactLabel(issue.labels, \"phase:discussion\")) {\n return { bucket: \"discuss\", item: base };\n }\n if (hasExactLabel(issue.labels, \"phase:ready-to-implement\")) {\n return { bucket: \"implement\", item: { ...base, assigned } };\n }\n\n // Keyword fallback (repos without the bot)\n if (hasLabel(issue.labels, \"vote\")) {\n return { bucket: \"voteOn\", item: base };\n }\n if (hasLabel(issue.labels, \"discuss\")) {\n return { bucket: \"discuss\", item: base };\n }\n\n return {\n bucket: \"implement\",\n item: { ...base, assigned },\n };\n}\n\nfunction classifyPR(\n pr: GitHubPR,\n now: Date,\n): { bucket: \"reviewPRs\" | \"addressFeedback\"; item: SummaryItem } {\n const age = timeAgo(pr.createdAt, now);\n const tags = pr.labels.map((l) => l.name);\n const author = pr.author?.login ?? \"ghost\";\n const comments = pr.comments.length;\n const ciFailing = hasCIFailure(pr);\n const checks = compactChecks(checkStatus(pr));\n const merge = compactMergeable(mergeStatus(pr));\n const review = {\n approvals: approvalCount(pr),\n changesRequested: changesRequestedCount(pr),\n };\n\n if (pr.isDraft || ciFailing || pr.reviewDecision === \"CHANGES_REQUESTED\" || changesRequestedCount(pr) > 0) {\n let status: string;\n if (pr.isDraft) status = \"draft\";\n else if (pr.reviewDecision === \"CHANGES_REQUESTED\" || changesRequestedCount(pr) > 0) status = \"changes-requested\";\n else status = \"waiting\";\n\n return {\n bucket: \"addressFeedback\",\n item: { number: pr.number, title: pr.title, tags, author, comments, age, status, checks, mergeable: merge, review },\n };\n }\n\n const status = pr.reviewDecision === \"APPROVED\" ? \"approved\" : \"waiting\";\n\n return {\n bucket: \"reviewPRs\",\n item: { number: pr.number, title: pr.title, tags, author, comments, age, status, checks, mergeable: merge, review },\n };\n}\n\nfunction buildCompetitionMap(prs: GitHubPR[], currentUser: string): Map<number, number> {\n const map = new Map<number, number>();\n for (const pr of prs) {\n if (!hasLabel(pr.labels, \"implementation\")) continue;\n if (pr.author?.login === currentUser) continue;\n for (const ref of pr.closingIssuesReferences) {\n map.set(ref.number, (map.get(ref.number) ?? 0) + 1);\n }\n }\n return map;\n}\n\nexport function buildSummary(\n repo: RepoRef,\n issues: GitHubIssue[],\n prs: GitHubPR[],\n currentUser: string,\n now: Date = new Date(),\n): RepoSummary {\n const voteOn: SummaryItem[] = [];\n const discuss: SummaryItem[] = [];\n const implement: SummaryItem[] = [];\n const reviewPRs: SummaryItem[] = [];\n const addressFeedback: SummaryItem[] = [];\n\n for (const issue of issues) {\n const { bucket, item } = classifyIssue(issue, now);\n if (bucket === \"voteOn\") voteOn.push(item);\n else if (bucket === \"discuss\") discuss.push(item);\n else if (bucket === \"implement\") implement.push(item);\n // \"needsHuman\" issues intentionally excluded from all buckets\n }\n\n // Annotate implement items with competing PR counts\n const competitionMap = buildCompetitionMap(prs, currentUser);\n for (const item of implement) {\n const count = competitionMap.get(item.number) ?? 0;\n if (count > 0) {\n item.competingPRs = count;\n }\n }\n\n for (const pr of prs) {\n const { bucket, item } = classifyPR(pr, now);\n if (bucket === \"reviewPRs\") reviewPRs.push(item);\n else addressFeedback.push(item);\n }\n\n const alerts = generateAlerts(issues, prs, now);\n\n // Extract authored items into \"drive\" buckets so the agent knows what it owns\n const driveDiscussion: SummaryItem[] = [];\n const driveImplementation: SummaryItem[] = [];\n\n const filteredDiscuss = discuss.filter((item) => {\n if (item.author === currentUser) { driveDiscussion.push(item); return false; }\n return true;\n });\n\n const filteredVoteOn = voteOn.filter((item) => {\n if (item.author === currentUser && item.tags.includes(\"phase:extended-voting\")) {\n driveDiscussion.push(item);\n return false;\n }\n return true;\n });\n\n const filteredReviewPRs = reviewPRs.filter((item) => {\n if (item.author === currentUser) { driveImplementation.push(item); return false; }\n return true;\n });\n\n const filteredAddressFeedback = addressFeedback.filter((item) => {\n if (item.author === currentUser) { driveImplementation.push(item); return false; }\n return true;\n });\n\n return {\n repo,\n currentUser,\n driveDiscussion,\n driveImplementation,\n voteOn: filteredVoteOn,\n discuss: filteredDiscuss,\n implement,\n reviewPRs: filteredReviewPRs,\n addressFeedback: filteredAddressFeedback,\n alerts,\n notes: [],\n };\n}\n","import chalk from \"chalk\";\nimport type { RepoSummary, RoleConfig, SummaryItem, TeamConfig } from \"../config/types.js\";\n\nconst DIVIDER_WIDTH = 50;\n\n// Section types determine which metadata keys appear on the second line\ntype SectionType = \"vote\" | \"discuss\" | \"implement\" | \"reviewPRs\" | \"addressFeedback\" | \"driveDiscussion\" | \"driveImplementation\";\n\nfunction sectionDivider(title: string, count: number): string {\n const label = ` ${title} (${count}) `;\n const remaining = Math.max(0, DIVIDER_WIDTH - label.length - 2);\n return chalk.dim(\"──\") + chalk.bold(label) + chalk.dim(\"─\".repeat(remaining));\n}\n\nfunction formatTags(tags: string[]): string {\n if (tags.length === 0) return \"\";\n return \" \" + tags.map((t) => chalk.magenta(`[${t}]`)).join(\" \");\n}\n\nfunction kv(key: string, value: string | number): string {\n return `${key}: ${chalk.dim(String(value))}`;\n}\n\nfunction formatMeta(item: SummaryItem, sectionType: SectionType, currentUser: string): string {\n const isYou = item.author === currentUser;\n const authorVal = isYou ? chalk.green(`${item.author} (you)`) : chalk.dim(item.author);\n const parts: string[] = [`by: ${authorVal}`];\n\n if (sectionType === \"implement\") {\n parts.push(kv(\"assigned\", item.assigned ?? \"--\"));\n parts.push(kv(\"comments\", item.comments));\n parts.push(kv(\"created\", item.age));\n if (item.competingPRs !== undefined) {\n parts.push(kv(\"competing\", item.competingPRs));\n }\n } else if (sectionType === \"vote\" || sectionType === \"discuss\" || sectionType === \"driveDiscussion\") {\n parts.push(kv(\"comments\", item.comments));\n parts.push(kv(\"created\", item.age));\n } else {\n // PR sections: reviewPRs, addressFeedback, driveImplementation\n if (item.status !== undefined) parts.push(kv(\"status\", item.status));\n if (item.checks !== undefined && item.checks !== null) parts.push(kv(\"checks\", item.checks));\n if (item.mergeable !== undefined && item.mergeable !== null) parts.push(kv(\"merge\", item.mergeable));\n if (item.review) parts.push(kv(\"review\", `${item.review.approvals} approved, ${item.review.changesRequested} changes-requested`));\n parts.push(kv(\"comments\", item.comments));\n parts.push(kv(\"created\", item.age));\n }\n\n return parts.join(\" \");\n}\n\nfunction formatItem(item: SummaryItem, currentUser: string, sectionType: SectionType): string {\n const isYou = item.author === currentUser;\n const prefix = isYou ? chalk.green(\"★\") : \" \";\n const num = chalk.cyan(`#${item.number}`);\n const tags = formatTags(item.tags);\n\n const titleLine = `${prefix} ${num} ${item.title}${tags}`;\n const metaLine = ` ${formatMeta(item, sectionType, currentUser)}`;\n\n return `${titleLine}\\n${metaLine}`;\n}\n\nfunction formatSection(\n title: string,\n items: SummaryItem[],\n currentUser: string,\n sectionType: SectionType,\n limit?: number,\n): string {\n if (items.length === 0) return \"\";\n\n const displayed = limit ? items.slice(0, limit) : items;\n const header = sectionDivider(title, items.length);\n const itemBlocks = displayed.map((item) => formatItem(item, currentUser, sectionType));\n\n const parts = [header, ...itemBlocks];\n\n if (limit && items.length > limit) {\n parts.push(chalk.dim(` ... and ${items.length - limit} more`));\n }\n\n return parts.join(\"\\n\\n\");\n}\n\nfunction formatSummaryBody(summary: RepoSummary, limit?: number): string {\n const u = summary.currentUser;\n const sections: string[] = [];\n\n // Attention items at the top\n if (summary.alerts.length > 0) {\n const alertLines = [\n sectionDivider(\"REQUIRES YOUR ATTENTION\", summary.alerts.length),\n ...summary.alerts.map((a) => ` ${a.icon} ${chalk.yellow(a.message)}`),\n ];\n sections.push(alertLines.join(\"\\n\"));\n }\n\n sections.push(\n ...[\n formatSection(\"DRIVE THE DISCUSSION\", summary.driveDiscussion, u, \"driveDiscussion\", limit),\n formatSection(\"DRIVE THE IMPLEMENTATION\", summary.driveImplementation, u, \"driveImplementation\", limit),\n formatSection(\"VOTE ON ISSUES\", summary.voteOn, u, \"vote\", limit),\n formatSection(\"DISCUSS ISSUES\", summary.discuss, u, \"discuss\", limit),\n formatSection(\"READY TO IMPLEMENT ISSUES\", summary.implement, u, \"implement\", limit),\n formatSection(\"REVIEW PRs\", summary.reviewPRs, u, \"reviewPRs\", limit),\n formatSection(\"ADDRESS FEEDBACK PRs\", summary.addressFeedback, u, \"addressFeedback\", limit),\n ].filter(Boolean),\n );\n\n if (summary.notes.length > 0) {\n sections.push(summary.notes.map((n) => chalk.dim(` ${n}`)).join(\"\\n\"));\n }\n\n if (sections.length === 0) {\n return chalk.dim(\" No open issues or PRs.\");\n }\n\n return sections.join(\"\\n\\n\");\n}\n\nexport function formatBuzz(\n roleName: string,\n role: RoleConfig,\n summary: RepoSummary,\n limit?: number,\n): string {\n const lines = [\n chalk.bold(`ROLE: ${roleName}`) + ` — ${role.description}`,\n \"\",\n chalk.bold(\"INSTRUCTIONS:\"),\n role.instructions.trimEnd(),\n \"\",\n summary.currentUser\n ? `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}, logged in as ${chalk.green(summary.currentUser)}`\n : `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}`,\n \"\",\n formatSummaryBody(summary, limit),\n ];\n\n return lines.join(\"\\n\");\n}\n\nexport function formatStatus(summary: RepoSummary, limit?: number): string {\n const lines = [\n summary.currentUser\n ? `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}, logged in as ${chalk.green(summary.currentUser)}`\n : `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}`,\n \"\",\n formatSummaryBody(summary, limit),\n ];\n\n return lines.join(\"\\n\");\n}\n\nexport function formatRoles(teamConfig: TeamConfig, repoFullName: string): string {\n const nameLabel = teamConfig.name ? ` (${teamConfig.name})` : \"\";\n const lines = [\n chalk.bold(`ROLES — ${repoFullName}${nameLabel}`),\n \"\",\n ];\n\n const slugs = Object.keys(teamConfig.roles);\n const maxLen = Math.max(...slugs.map((s) => s.length));\n\n for (const slug of slugs) {\n const role = teamConfig.roles[slug];\n const padded = slug.padEnd(maxLen + 2);\n lines.push(` ${chalk.cyan(padded)}${role.description}`);\n }\n\n return lines.join(\"\\n\");\n}\n","import type { RepoSummary, RoleConfig, TeamConfig } from \"../config/types.js\";\n\nexport function jsonBuzz(\n roleName: string,\n role: RoleConfig,\n summary: RepoSummary,\n): string {\n return JSON.stringify(\n {\n role: {\n name: roleName,\n description: role.description,\n instructions: role.instructions,\n },\n summary: {\n repo: `${summary.repo.owner}/${summary.repo.repo}`,\n currentUser: summary.currentUser,\n driveDiscussion: summary.driveDiscussion,\n driveImplementation: summary.driveImplementation,\n voteOn: summary.voteOn,\n discuss: summary.discuss,\n implement: summary.implement,\n reviewPRs: summary.reviewPRs,\n addressFeedback: summary.addressFeedback,\n alerts: summary.alerts,\n notes: summary.notes,\n },\n },\n null,\n 2,\n );\n}\n\nexport function jsonStatus(summary: RepoSummary): string {\n return JSON.stringify(\n {\n repo: `${summary.repo.owner}/${summary.repo.repo}`,\n currentUser: summary.currentUser,\n driveDiscussion: summary.driveDiscussion,\n driveImplementation: summary.driveImplementation,\n voteOn: summary.voteOn,\n discuss: summary.discuss,\n implement: summary.implement,\n reviewPRs: summary.reviewPRs,\n addressFeedback: summary.addressFeedback,\n alerts: summary.alerts,\n notes: summary.notes,\n },\n null,\n 2,\n );\n}\n\nexport function jsonRoles(teamConfig: TeamConfig): string {\n const roles = Object.entries(teamConfig.roles).map(([slug, role]) => ({\n name: slug,\n description: role.description,\n }));\n\n return JSON.stringify({ roles }, null, 2);\n}\n","import { CliError, type BuzzOptions } from \"../config/types.js\";\nimport { loadTeamConfig } from \"../config/loader.js\";\nimport { resolveRepo } from \"../github/repo.js\";\nimport { fetchIssues } from \"../github/issues.js\";\nimport { fetchPulls } from \"../github/pulls.js\";\nimport { fetchCurrentUser } from \"../github/user.js\";\nimport { buildSummary } from \"../summary/builder.js\";\nimport { formatBuzz, formatStatus } from \"../output/formatter.js\";\nimport { jsonBuzz, jsonStatus } from \"../output/json.js\";\n\nfunction errorDetail(reason: unknown): string {\n return reason instanceof Error ? reason.message : String(reason);\n}\n\nexport async function buzzCommand(options: BuzzOptions): Promise<void> {\n const repo = await resolveRepo(options.repo);\n const fetchLimit = options.fetchLimit ?? 200;\n\n const [issuesResult, prsResult, userResult] = await Promise.allSettled([\n fetchIssues(repo, fetchLimit),\n fetchPulls(repo, fetchLimit),\n fetchCurrentUser(),\n ]);\n\n // If all three failed, surface the most actionable CliError.\n if (\n issuesResult.status === \"rejected\" &&\n prsResult.status === \"rejected\" &&\n userResult.status === \"rejected\"\n ) {\n const cliErrors = [issuesResult, prsResult, userResult]\n .map((r) => r.reason)\n .filter((r): r is CliError => r instanceof CliError);\n const actionableCodes = [\"GH_NOT_AUTHENTICATED\", \"RATE_LIMITED\", \"GH_NOT_FOUND\"];\n const best = cliErrors.find((e) => actionableCodes.includes(e.code)) ?? cliErrors[0];\n throw best ?? issuesResult.reason;\n }\n\n const issues = issuesResult.status === \"fulfilled\" ? issuesResult.value : [];\n const prs = prsResult.status === \"fulfilled\" ? prsResult.value : [];\n const currentUser = userResult.status === \"fulfilled\" ? userResult.value : \"\";\n\n const summary = buildSummary(repo, issues, prs, currentUser);\n\n if (issuesResult.status === \"rejected\" && prsResult.status === \"rejected\") {\n summary.notes.push(\n `Could not fetch issues (${errorDetail(issuesResult.reason)}) or pull requests (${errorDetail(prsResult.reason)}) — showing limited summary.`,\n );\n } else if (issuesResult.status === \"rejected\") {\n summary.notes.push(`Could not fetch issues (${errorDetail(issuesResult.reason)}) — showing PRs only.`);\n } else if (prsResult.status === \"rejected\") {\n summary.notes.push(`Could not fetch pull requests (${errorDetail(prsResult.reason)}) — showing issues only.`);\n }\n\n if (userResult.status === \"rejected\") {\n summary.notes.push(\n `Could not determine GitHub user (${errorDetail(userResult.reason)}) — drive sections, competition counts, and author highlighting are unavailable.`,\n );\n }\n\n if (issues.length >= fetchLimit) {\n summary.notes.push(`Only the first ${fetchLimit} issues were fetched. Use --fetch-limit to increase.`);\n }\n if (prs.length >= fetchLimit) {\n summary.notes.push(`Only the first ${fetchLimit} PRs were fetched. Use --fetch-limit to increase.`);\n }\n\n if (options.role) {\n const teamConfig = await loadTeamConfig(repo);\n if (!Object.hasOwn(teamConfig.roles, options.role)) {\n const available = Object.keys(teamConfig.roles).join(\", \");\n throw new CliError(\n `Role '${options.role}' not found. Available: ${available}. Run: hivemoot roles`,\n \"ROLE_NOT_FOUND\",\n 1,\n );\n }\n const roleConfig = teamConfig.roles[options.role];\n\n if (options.json) {\n console.log(jsonBuzz(options.role, roleConfig, summary));\n } else {\n console.log(formatBuzz(options.role, roleConfig, summary, options.limit));\n }\n } else {\n if (options.json) {\n console.log(jsonStatus(summary));\n } else {\n console.log(formatStatus(summary, options.limit));\n }\n }\n}\n","import type { RolesOptions } from \"../config/types.js\";\nimport { loadTeamConfig } from \"../config/loader.js\";\nimport { resolveRepo } from \"../github/repo.js\";\nimport { formatRoles } from \"../output/formatter.js\";\nimport { jsonRoles } from \"../output/json.js\";\n\nexport async function rolesCommand(options: RolesOptions): Promise<void> {\n const repo = await resolveRepo(options.repo);\n const teamConfig = await loadTeamConfig(repo);\n\n if (options.json) {\n console.log(jsonRoles(teamConfig));\n } else {\n console.log(formatRoles(teamConfig, `${repo.owner}/${repo.repo}`));\n }\n}\n","export async function initCommand(): Promise<void> {\n const template = `# Hivemoot team configuration\n# Place this file at .github/hivemoot.yml in your repository.\n#\n# Roles define personas (who the agent is), not workflow.\n# Workflow details belong in .agent/skills/.\n\nteam:\n roles:\n pm:\n description: \"Product manager focused on user value and clarity\"\n instructions: |\n You think from the user's perspective.\n Evaluate ideas by the problem they solve and who benefits.\n Push for clear requirements and well-scoped proposals.\n Ask \"why does this matter?\" before \"how do we build it?\"\n\n engineer:\n description: \"Software engineer focused on clean implementation\"\n instructions: |\n You care about code quality, patterns, and maintainability.\n Favor simple, proven approaches over clever solutions.\n Write clean code with good test coverage.\n Build on existing conventions in the codebase.\n\n architect:\n description: \"Architect focused on system design and long-term health\"\n instructions: |\n You think about how pieces fit together.\n Evaluate proposals for scalability, consistency, and technical debt.\n Guard the system's boundaries and abstractions.\n Push back when short-term wins create long-term problems.\n\n qa:\n description: \"QA engineer focused on reliability and edge cases\"\n instructions: |\n You think about what can go wrong.\n Find edge cases, race conditions, and failure modes others miss.\n Push for thorough error handling and defensive design.\n Ask \"what happens when this fails?\" about everything.\n`;\n\n console.log(template);\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,4BAA4B;;;AC2IvC,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACE,SACgB,MACA,WAAmB,GACnC;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACrJA,OAAO,UAAU;;;ACAjB,SAAS,gBAA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AACvC,SAAS,KAAK;AACZ,MAAI,eAAe,UAAU;AAE3B,UAAM,SAAS,QAAQ,KAAK,SAAS,QAAQ;AAC7C,QAAI,QAAQ;AACV,cAAQ,IAAI,KAAK,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC;AAAA,IAC1F,OAAO;AACL,cAAQ,MAAM,UAAU,IAAI,OAAO,EAAE;AAAA,IACvC;AACA,YAAQ,KAAK,IAAI,QAAQ;AAAA,EAC3B;AAGA,MAAI,eAAe,SAAS,cAAc,KAAK;AAC7C,UAAM,WAAY,IAAqC;AACvD,YAAQ,KAAK,QAAQ;AAAA,EACvB;AAEA,UAAQ,MAAM,qBAAqB,GAAG;AACtC,UAAQ,KAAK,CAAC;AAChB;","names":["status","require"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config/types.ts","../src/config/loader.ts","../src/github/client.ts","../src/github/repo.ts","../src/github/issues.ts","../src/github/pulls.ts","../src/github/user.ts","../src/summary/utils.ts","../src/summary/builder.ts","../src/output/formatter.ts","../src/output/json.ts","../src/commands/buzz.ts","../src/commands/roles.ts","../src/commands/init.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { Command, InvalidArgumentError } from \"commander\";\nimport { buzzCommand } from \"./commands/buzz.js\";\nimport { rolesCommand } from \"./commands/roles.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { CliError } from \"./config/types.js\";\nimport { setGhToken } from \"./github/client.js\";\n\nconst require = createRequire(import.meta.url);\nconst { version } = require(\"../package.json\") as { version: string };\n\nfunction parseLimit(value: string): number {\n const n = parseInt(value, 10);\n if (isNaN(n) || n <= 0) {\n throw new InvalidArgumentError(\"Must be a positive integer.\");\n }\n return n;\n}\n\nconst program = new Command();\n\nprogram\n .name(\"hivemoot\")\n .description(\"CLI for Hivemoot agents — role instructions and repo work summaries\")\n .version(version)\n .option(\"--github-token <token>\", \"GitHub personal access token (or set GITHUB_TOKEN env var)\");\n\nprogram.hook(\"preAction\", () => {\n const token = (program.opts().githubToken ?? process.env.GITHUB_TOKEN) as string | undefined;\n if (token) {\n setGhToken(token);\n }\n});\n\nprogram\n .command(\"buzz\")\n .description(\"Get role instructions and repo work summary (omit --role for summary only)\")\n .option(\"--role <role>\", \"Role to assume (e.g. engineer, tech_lead)\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--limit <n>\", \"Max items per section\", parseLimit)\n .option(\"--fetch-limit <n>\", \"Max issues/PRs to fetch from GitHub (default: 200)\", parseLimit)\n .option(\"--repo <owner/repo>\", \"Target repository (default: detect from git)\")\n .action(buzzCommand);\n\nprogram\n .command(\"roles\")\n .description(\"List available roles from team config\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--repo <owner/repo>\", \"Target repository (default: detect from git)\")\n .action(rolesCommand);\n\nprogram\n .command(\"init\")\n .description(\"Print a sample .github/hivemoot.yml template\")\n .action(initCommand);\n\n// Global error handler\nprogram.exitOverride();\n\ntry {\n await program.parseAsync(process.argv);\n} catch (err) {\n if (err instanceof CliError) {\n // Check if parent command requested --json output\n const isJson = process.argv.includes(\"--json\");\n if (isJson) {\n console.log(JSON.stringify({ error: { code: err.code, message: err.message } }, null, 2));\n } else {\n console.error(`Error: ${err.message}`);\n }\n process.exit(err.exitCode);\n }\n\n // Commander exits for --help, --version, etc.\n if (err instanceof Error && \"exitCode\" in err) {\n const exitCode = (err as Error & { exitCode: number }).exitCode;\n process.exit(exitCode);\n }\n\n console.error(\"Unexpected error:\", err);\n process.exit(1);\n}\n","// ── YAML Config Types ──────────────────────────────────────────────\n\nexport interface RoleConfig {\n description: string;\n instructions: string;\n}\n\nexport interface TeamConfig {\n name?: string;\n roles: Record<string, RoleConfig>;\n}\n\nexport interface HivemootConfig {\n version?: number;\n governance?: unknown;\n team?: TeamConfig;\n}\n\n// ── GitHub Data Types ──────────────────────────────────────────────\n\nexport interface GitHubIssue {\n number: number;\n title: string;\n labels: Array<{ name: string }>;\n assignees: Array<{ login: string }>;\n author: { login: string } | null;\n comments: Array<{ createdAt: string }>;\n createdAt: string;\n updatedAt: string;\n url: string;\n}\n\nexport interface StatusCheck {\n context: string;\n state: string | undefined;\n conclusion: string | null;\n}\n\nexport interface PRReview {\n state: string;\n author: { login: string } | null;\n submittedAt?: string;\n}\n\nexport interface PRCommit {\n committedDate: string;\n}\n\nexport interface GitHubPR {\n number: number;\n title: string;\n state: string;\n author: { login: string } | null;\n labels: Array<{ name: string }>;\n comments: Array<{ createdAt: string }>;\n reviews: PRReview[];\n createdAt: string;\n updatedAt: string;\n url: string;\n isDraft: boolean;\n reviewDecision: string;\n mergeable: string;\n statusCheckRollup: StatusCheck[] | null;\n closingIssuesReferences: Array<{ number: number }>;\n commits: PRCommit[];\n}\n\n// ── Repo Identity ──────────────────────────────────────────────────\n\nexport interface RepoRef {\n owner: string;\n repo: string;\n}\n\n// ── Summary Types ──────────────────────────────────────────────────\n\nexport interface ReviewSummary {\n approvals: number;\n changesRequested: number;\n}\n\nexport interface SummaryItem {\n number: number;\n title: string;\n tags: string[];\n author: string;\n // Common fields\n comments: number;\n age: string; // \"just now\" | \"5 minutes ago\" | \"2 hours ago\" | \"3 days ago\"\n // Issue-specific\n assigned?: string; // comma-separated logins, or undefined (= unassigned)\n competingPRs?: number; // only on implement items with competing PRs\n // PR-specific\n status?: string; // \"pending\" | \"approved\" | \"changes-requested\" | \"draft\"\n checks?: string | null; // \"passing\" | \"failing\" | \"pending\" | null\n mergeable?: string | null; // \"clean\" | \"conflicts\" | null\n review?: ReviewSummary;\n yourReview?: string;\n yourReviewAge?: string; // \"3 days ago\" — when you last reviewed\n lastCommit?: string; // \"2 hours ago\" — when the latest commit landed\n lastComment?: string; // \"5 hours ago\" — when the latest comment was posted\n updated?: string; // \"30 minutes ago\" — pr.updatedAt (catch-all)\n}\n\nexport interface RepoSummary {\n repo: RepoRef;\n currentUser: string;\n needsHuman: SummaryItem[];\n driveDiscussion: SummaryItem[];\n driveImplementation: SummaryItem[];\n voteOn: SummaryItem[];\n discuss: SummaryItem[];\n implement: SummaryItem[];\n reviewPRs: SummaryItem[];\n addressFeedback: SummaryItem[];\n notes: string[];\n}\n\n// ── CLI Options ────────────────────────────────────────────────────\n\nexport interface BuzzOptions {\n role?: string;\n json?: boolean;\n limit?: number;\n fetchLimit?: number;\n repo?: string;\n}\n\nexport interface RolesOptions {\n json?: boolean;\n repo?: string;\n}\n\n// ── Error Types ────────────────────────────────────────────────────\n\nexport type ErrorCode =\n | \"GH_NOT_FOUND\"\n | \"GH_NOT_AUTHENTICATED\"\n | \"NOT_GIT_REPO\"\n | \"CONFIG_NOT_FOUND\"\n | \"NO_TEAM_CONFIG\"\n | \"ROLE_NOT_FOUND\"\n | \"INVALID_CONFIG\"\n | \"RATE_LIMITED\"\n | \"GH_ERROR\";\n\nexport class CliError extends Error {\n constructor(\n message: string,\n public readonly code: ErrorCode,\n public readonly exitCode: number = 1,\n ) {\n super(message);\n this.name = \"CliError\";\n }\n}\n","import yaml from \"js-yaml\";\nimport { gh } from \"../github/client.js\";\nimport type { HivemootConfig, TeamConfig, RepoRef, RoleConfig } from \"./types.js\";\nimport { CliError } from \"./types.js\";\n\nconst ROLE_SLUG_RE = /^[a-z][a-z0-9_]{0,49}$/;\nconst MAX_DESCRIPTION_LENGTH = 500;\nconst MAX_INSTRUCTIONS_LENGTH = 10_000;\n\nfunction validateTeamConfig(raw: HivemootConfig): TeamConfig {\n if (!raw.team) {\n throw new CliError(\n \"No team config in .github/hivemoot.yml. Run: hivemoot init\",\n \"NO_TEAM_CONFIG\",\n 1,\n );\n }\n\n const { team } = raw;\n\n if (!team.roles || typeof team.roles !== \"object\" || Object.keys(team.roles).length === 0) {\n throw new CliError(\n \"Config error: team.roles must contain at least one role\",\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n const validatedRoles: Record<string, RoleConfig> = {};\n\n for (const [slug, role] of Object.entries(team.roles)) {\n if (!ROLE_SLUG_RE.test(slug)) {\n throw new CliError(\n `Config error: invalid role slug \"${slug}\" — must match /^[a-z][a-z0-9_]{0,49}$/`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (typeof role !== \"object\" || role === null) {\n throw new CliError(\n `Config error: role \"${slug}\" must be an object`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n const r = role as unknown as Record<string, unknown>;\n\n if (typeof r.description !== \"string\" || r.description.length === 0) {\n throw new CliError(\n `Config error: role \"${slug}\" is missing a description`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (r.description.length > MAX_DESCRIPTION_LENGTH) {\n throw new CliError(\n `Config error: role \"${slug}\" description exceeds ${MAX_DESCRIPTION_LENGTH} characters`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (typeof r.instructions !== \"string\" || r.instructions.length === 0) {\n throw new CliError(\n `Config error: role \"${slug}\" is missing instructions`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (r.instructions.length > MAX_INSTRUCTIONS_LENGTH) {\n throw new CliError(\n `Config error: role \"${slug}\" instructions exceeds ${MAX_INSTRUCTIONS_LENGTH} characters`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n validatedRoles[slug] = {\n description: r.description,\n instructions: r.instructions,\n };\n }\n\n return {\n name: typeof team.name === \"string\" ? team.name : undefined,\n roles: validatedRoles,\n };\n}\n\nexport async function loadTeamConfig(repo: RepoRef): Promise<TeamConfig> {\n let rawJson: string;\n\n try {\n rawJson = await gh([\n \"api\",\n `repos/${repo.owner}/${repo.repo}/contents/.github/hivemoot.yml`,\n ]);\n } catch (err) {\n if (err instanceof Error && /404|Not Found/i.test(err.message)) {\n throw new CliError(\n \"No .github/hivemoot.yml found. Run: hivemoot init\",\n \"CONFIG_NOT_FOUND\",\n 1,\n );\n }\n throw err;\n }\n\n let content: string;\n try {\n const parsed = JSON.parse(rawJson);\n content = Buffer.from(parsed.content, \"base64\").toString(\"utf-8\");\n } catch (err) {\n const detail = err instanceof Error ? `: ${err.message}` : \"\";\n throw new CliError(\n `Config error: failed to decode .github/hivemoot.yml content${detail}`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n let config: HivemootConfig;\n try {\n config = yaml.load(content, { schema: yaml.JSON_SCHEMA }) as HivemootConfig;\n } catch (err) {\n const detail = err instanceof Error ? `: ${err.message}` : \"\";\n throw new CliError(\n `Config error: invalid YAML in .github/hivemoot.yml${detail}`,\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n if (typeof config !== \"object\" || config === null) {\n throw new CliError(\n \"Config error: .github/hivemoot.yml must be a YAML object\",\n \"INVALID_CONFIG\",\n 1,\n );\n }\n\n return validateTeamConfig(config);\n}\n","import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { CliError } from \"../config/types.js\";\n\nconst execFileAsync = promisify(execFile);\n\nlet ghToken: string | undefined;\n\n/** Set the GitHub token used for all subsequent `gh` calls. */\nexport function setGhToken(token: string): void {\n ghToken = token;\n}\n\n/**\n * Execute a `gh` CLI command and return stdout.\n * All GitHub I/O goes through this single function.\n */\nexport async function gh(args: string[]): Promise<string> {\n try {\n const opts: { timeout: number; env?: NodeJS.ProcessEnv } = {\n timeout: 30_000,\n };\n if (ghToken) {\n opts.env = { ...process.env, GH_TOKEN: ghToken };\n }\n const { stdout } = await execFileAsync(\"gh\", args, opts);\n return stdout.trim();\n } catch (err: unknown) {\n const error = err as NodeJS.ErrnoException & {\n stderr?: string;\n code?: string | number;\n };\n\n if (error.code === \"ENOENT\") {\n throw new CliError(\n \"gh CLI not found. Install: https://cli.github.com\",\n \"GH_NOT_FOUND\",\n 2,\n );\n }\n\n const stderr = error.stderr ?? error.message ?? \"\";\n\n if (/gh auth login|not logged in|authentication required/i.test(stderr)) {\n throw new CliError(\n \"Not authenticated. Pass --github-token <token>, set GITHUB_TOKEN, or run: gh auth login\",\n \"GH_NOT_AUTHENTICATED\",\n 2,\n );\n }\n\n if (/rate.?limit|API rate limit/i.test(stderr)) {\n throw new CliError(\n \"GitHub rate limited. Try again later.\",\n \"RATE_LIMITED\",\n 3,\n );\n }\n\n throw new CliError(stderr || \"gh command failed\", \"GH_ERROR\", 1);\n }\n}\n","import { CliError, type RepoRef } from \"../config/types.js\";\nimport { gh } from \"./client.js\";\n\nconst GITHUB_NAME_RE = /^[a-zA-Z0-9._-]+$/;\n\nexport async function resolveRepo(repoFlag?: string): Promise<RepoRef> {\n if (repoFlag) {\n const parts = repoFlag.split(\"/\");\n if (parts.length !== 2 || !parts[0] || !parts[1]) {\n throw new CliError(\n `Invalid repo format: \"${repoFlag}\". Expected OWNER/REPO`,\n \"GH_ERROR\",\n 1,\n );\n }\n if (!GITHUB_NAME_RE.test(parts[0]) || !GITHUB_NAME_RE.test(parts[1])) {\n throw new CliError(\n `Invalid repo name: \"${repoFlag}\". Owner and repo must match ${GITHUB_NAME_RE}`,\n \"GH_ERROR\",\n 1,\n );\n }\n return { owner: parts[0], repo: parts[1] };\n }\n\n try {\n const json = await gh([\"repo\", \"view\", \"--json\", \"owner,name\"]);\n let data: { owner?: { login?: string } | string; name?: string };\n try {\n data = JSON.parse(json);\n } catch {\n throw new CliError(\n \"Failed to parse repo info from gh CLI. Use --repo OWNER/REPO\",\n \"GH_ERROR\",\n 1,\n );\n }\n // gh returns owner as an object { login: \"...\" } not a plain string\n const owner =\n typeof data.owner === \"object\" && data.owner !== null\n ? data.owner.login\n : data.owner;\n const name = data.name;\n if (typeof owner !== \"string\" || !owner || typeof name !== \"string\" || !name) {\n throw new CliError(\n \"Could not detect repo owner/name. Use --repo OWNER/REPO\",\n \"NOT_GIT_REPO\",\n 2,\n );\n }\n return { owner, repo: name };\n } catch (err) {\n if (err instanceof CliError) {\n throw err;\n }\n throw new CliError(\n \"Not in a git repository. Use --repo OWNER/REPO\",\n \"NOT_GIT_REPO\",\n 2,\n );\n }\n}\n","import type { GitHubIssue, RepoRef } from \"../config/types.js\";\nimport { CliError } from \"../config/types.js\";\nimport { gh } from \"./client.js\";\n\nexport async function fetchIssues(repo: RepoRef, limit = 200): Promise<GitHubIssue[]> {\n const json = await gh([\n \"issue\",\n \"list\",\n \"-R\",\n `${repo.owner}/${repo.repo}`,\n \"--state\",\n \"open\",\n \"--json\",\n \"number,title,labels,assignees,author,comments,createdAt,updatedAt,url\",\n \"--limit\",\n String(limit),\n ]);\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n throw new CliError(\n \"Failed to parse issues response from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n if (!Array.isArray(parsed)) {\n throw new CliError(\n \"Unexpected issues response format from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n return parsed as GitHubIssue[];\n}\n","import type { GitHubPR, RepoRef } from \"../config/types.js\";\nimport { CliError } from \"../config/types.js\";\nimport { gh } from \"./client.js\";\n\n/**\n * Fetch the latest commit date for each open PR via GraphQL.\n *\n * `gh pr list --json commits` requests the full commits connection, whose\n * `authors` sub-connection blows through GitHub's 500k node budget on repos\n * with many PRs. Using `commits(last: 1)` avoids this entirely — we only\n * need the most recent commit date per PR.\n *\n * GitHub caps `first` at 100, so we paginate with cursors when limit > 100.\n */\nasync function fetchLatestCommitDates(\n repo: RepoRef,\n limit: number,\n): Promise<Map<number, string>> {\n const query = `\n query($owner: String!, $name: String!, $pageSize: Int!, $cursor: String) {\n repository(owner: $owner, name: $name) {\n pullRequests(first: $pageSize, after: $cursor, states: OPEN, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo { hasNextPage endCursor }\n nodes {\n number\n commits(last: 1) { nodes { commit { committedDate } } }\n }\n }\n }\n }`;\n\n const PAGE_SIZE = 100;\n const map = new Map<number, string>();\n let remaining = limit;\n let cursor: string | null = null;\n\n while (remaining > 0) {\n const pageSize = Math.min(remaining, PAGE_SIZE);\n const args = [\n \"api\", \"graphql\",\n \"-F\", `owner=${repo.owner}`,\n \"-F\", `name=${repo.repo}`,\n \"-F\", `pageSize=${pageSize}`,\n \"-f\", `query=${query}`,\n ];\n if (cursor) {\n args.push(\"-F\", `cursor=${cursor}`);\n } else {\n // gh sends null when the variable is absent, which GraphQL accepts for String?\n args.push(\"-f\", \"cursor=\");\n }\n\n const json = await gh(args);\n const data = JSON.parse(json);\n const prs = data?.data?.repository?.pullRequests;\n const nodes: Array<{ number: number; commits: { nodes: Array<{ commit: { committedDate: string } }> } }>\n = prs?.nodes ?? [];\n\n for (const pr of nodes) {\n const commit = pr.commits.nodes[0];\n if (commit) map.set(pr.number, commit.commit.committedDate);\n }\n\n remaining -= nodes.length;\n const hasNext = prs?.pageInfo?.hasNextPage === true;\n if (!hasNext || nodes.length === 0) break;\n cursor = prs.pageInfo.endCursor;\n }\n\n return map;\n}\n\nexport async function fetchPulls(repo: RepoRef, limit = 200): Promise<GitHubPR[]> {\n // Fetch PR data and latest commit dates in parallel.\n // The main query omits `commits` to stay within GitHub's GraphQL node budget.\n const [listJson, commitDates] = await Promise.all([\n gh([\n \"pr\", \"list\",\n \"-R\", `${repo.owner}/${repo.repo}`,\n \"--state\", \"open\",\n \"--json\", \"number,title,state,author,labels,comments,reviews,createdAt,updatedAt,url,isDraft,reviewDecision,mergeable,statusCheckRollup,closingIssuesReferences\",\n \"--limit\", String(limit),\n ]),\n fetchLatestCommitDates(repo, limit),\n ]);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(listJson);\n } catch {\n throw new CliError(\n \"Failed to parse pull requests response from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n if (!Array.isArray(parsed)) {\n throw new CliError(\n \"Unexpected pull requests response format from gh CLI\",\n \"GH_ERROR\",\n 1,\n );\n }\n\n // Stitch the latest commit date back into each PR as a single-element array\n // so downstream code (`latestCommitAge`) works unchanged.\n const prs = parsed as GitHubPR[];\n for (const pr of prs) {\n const date = commitDates.get(pr.number);\n pr.commits = date ? [{ committedDate: date }] : [];\n }\n\n return prs;\n}\n","import { gh } from \"./client.js\";\nimport { CliError } from \"../config/types.js\";\n\n/**\n * Return the login of the currently authenticated GitHub user.\n */\nexport async function fetchCurrentUser(): Promise<string> {\n const login = await gh([\"api\", \"user\", \"--jq\", \".login\"]);\n if (!login) {\n throw new CliError(\n \"Could not determine GitHub username. Pass --github-token <token>, set GITHUB_TOKEN, or run: gh auth login\",\n \"GH_NOT_AUTHENTICATED\",\n 2,\n );\n }\n return login;\n}\n","import type { GitHubPR } from \"../config/types.js\";\n\nexport function hasLabel(labels: Array<{ name: string }>, keyword: string): boolean {\n return labels.some((l) =>\n l.name.toLowerCase().split(/[:\\-_]/).some((seg) => seg === keyword),\n );\n}\n\nexport function hasExactLabel(labels: Array<{ name: string }>, labelName: string): boolean {\n return labels.some((l) => l.name.toLowerCase() === labelName.toLowerCase());\n}\n\n/** Human-relative time string (\"just now\", \"5 minutes ago\", \"yesterday\", etc.). */\nexport function timeAgo(dateStr: string, now: Date): string {\n const ms = now.getTime() - new Date(dateStr).getTime();\n if (ms < 0) return \"just now\"; // future date — clock skew or bad data\n\n const minutes = Math.floor(ms / 60_000);\n const hours = Math.floor(ms / 3_600_000);\n const days = Math.floor(ms / 86_400_000);\n\n if (minutes < 1) return \"just now\";\n if (minutes < 60) return `${minutes}m ago`;\n if (hours < 24) {\n const remainingMinutes = minutes % 60;\n if (remainingMinutes === 0) return `${hours}h ago`;\n return `${hours}h${remainingMinutes}m ago`;\n }\n if (days === 1) return \"yesterday\";\n if (days < 7) return `${days} days ago`;\n if (days < 14) return \"1 week ago\";\n if (days < 30) return `${Math.floor(days / 7)} weeks ago`;\n if (days < 60) return \"1 month ago\";\n if (days < 365) return `${Math.floor(days / 30)} months ago`;\n const years = Math.floor(days / 365);\n if (years === 1) return \"1 year ago\";\n return `${years} years ago`;\n}\n\nexport function daysSince(dateStr: string, now: Date): number {\n const diff = now.getTime() - new Date(dateStr).getTime();\n return Math.max(0, Math.floor(diff / (1000 * 60 * 60 * 24)));\n}\n\nexport function hasCIFailure(pr: GitHubPR): boolean {\n if (!pr.statusCheckRollup) return false;\n return pr.statusCheckRollup.some((check) => {\n const conclusion = check.conclusion?.toUpperCase();\n const state = check.state?.toUpperCase();\n return conclusion === \"FAILURE\" || state === \"FAILURE\";\n });\n}\n\n/**\n * Summarize all status checks into a single label.\n * Returns null when there are no checks to report.\n */\nexport function checkStatus(pr: GitHubPR): string | null {\n if (!pr.statusCheckRollup || pr.statusCheckRollup.length === 0) return null;\n\n const hasFailing = hasCIFailure(pr);\n if (hasFailing) return \"checks failing\";\n\n const hasPending = pr.statusCheckRollup.some((c) => {\n const s = c.state?.toUpperCase();\n return s === \"PENDING\" || s === \"QUEUED\" || s === \"IN_PROGRESS\";\n });\n if (hasPending) return \"checks pending\";\n\n return \"checks passing\";\n}\n\n/**\n * Return a merge-conflict label, or null if no conflict info.\n */\nexport function mergeStatus(pr: GitHubPR): string | null {\n if (pr.mergeable === \"CONFLICTING\") return \"has conflicts\";\n if (pr.mergeable === \"MERGEABLE\") return \"no conflicts\";\n return null;\n}\n\n/** Collapse reviews to the latest state per author. */\nfunction latestReviewByAuthor(pr: GitHubPR): Map<string, string> {\n const map = new Map<string, string>();\n for (const review of pr.reviews ?? []) {\n map.set(review.author?.login ?? \"ghost\", review.state);\n }\n return map;\n}\n\n/** Count unique approvals (latest review per author). */\nexport function approvalCount(pr: GitHubPR): number {\n let count = 0;\n for (const state of latestReviewByAuthor(pr).values()) {\n if (state === \"APPROVED\") count++;\n }\n return count;\n}\n\n/**\n * Count unique changes-requested reviews (latest review per author).\n * If an author requests changes then later approves, they are no longer counted.\n */\nexport function changesRequestedCount(pr: GitHubPR): number {\n let count = 0;\n for (const state of latestReviewByAuthor(pr).values()) {\n if (state === \"CHANGES_REQUESTED\") count++;\n }\n return count;\n}\n\n// ── Review context ────────────────────────────────────────────────\n\nexport interface ReviewContext {\n yourReview: string;\n yourReviewAge: string;\n}\n\n/**\n * Compute the current user's review relationship to a PR.\n * Returns null if the user has not reviewed this PR.\n */\nexport function reviewContext(pr: GitHubPR, currentUser: string, now: Date): ReviewContext | null {\n // Find currentUser's latest review (gh returns chronologically, last wins)\n let latestState: string | undefined;\n let latestTime: string | undefined;\n for (const review of pr.reviews ?? []) {\n if (review.author?.login === currentUser) {\n latestState = review.state;\n latestTime = review.submittedAt;\n }\n }\n\n if (!latestState) return null;\n\n const stateMap: Record<string, string> = {\n CHANGES_REQUESTED: \"changes-requested\",\n APPROVED: \"approved\",\n COMMENTED: \"commented\",\n DISMISSED: \"dismissed\",\n };\n const yourReview = stateMap[latestState] ?? latestState.toLowerCase();\n const yourReviewAge = latestTime ? timeAgo(latestTime, now) : \"unknown\";\n\n return { yourReview, yourReviewAge };\n}\n\n// ── Temporal helpers ──────────────────────────────────────────────\n\n/** Relative time of the most recent commit, or undefined if no commits. */\nexport function latestCommitAge(pr: GitHubPR, now: Date): string | undefined {\n const commits = pr.commits ?? [];\n if (commits.length === 0) return undefined;\n let latest = commits[0].committedDate;\n for (let i = 1; i < commits.length; i++) {\n if (commits[i].committedDate > latest) latest = commits[i].committedDate;\n }\n return timeAgo(latest, now);\n}\n\n/** Relative time of the most recent comment, or undefined if no comments. */\nexport function latestCommentAge(item: { comments: Array<{ createdAt: string }> }, now: Date): string | undefined {\n if (item.comments.length === 0) return undefined;\n let latest = item.comments[0].createdAt;\n for (let i = 1; i < item.comments.length; i++) {\n if (item.comments[i].createdAt > latest) latest = item.comments[i].createdAt;\n }\n return timeAgo(latest, now);\n}\n","import type {\n GitHubIssue,\n GitHubPR,\n RepoRef,\n RepoSummary,\n SummaryItem,\n} from \"../config/types.js\";\nimport { hasLabel, hasExactLabel, hasCIFailure, checkStatus, mergeStatus, approvalCount, changesRequestedCount, timeAgo, reviewContext, latestCommitAge, latestCommentAge } from \"./utils.js\";\n\n/** Map verbose check labels to compact values for structured output. */\nfunction compactChecks(raw: string | null): string | null {\n if (raw === null) return null;\n if (raw === \"checks failing\") return \"failing\";\n if (raw === \"checks pending\") return \"pending\";\n if (raw === \"checks passing\") return \"passing\";\n return raw;\n}\n\n/** Map verbose merge labels to compact values for structured output. */\nfunction compactMergeable(raw: string | null): string | null {\n if (raw === null) return null;\n if (raw === \"has conflicts\") return \"conflicts\";\n if (raw === \"no conflicts\") return \"clean\";\n return raw;\n}\n\nfunction classifyIssue(\n issue: GitHubIssue,\n now: Date,\n): { bucket: \"voteOn\" | \"discuss\" | \"implement\" | \"needsHuman\"; item: SummaryItem } {\n const age = timeAgo(issue.createdAt, now);\n const assigned =\n issue.assignees.length > 0\n ? issue.assignees.map((a) => a.login).join(\", \")\n : undefined;\n\n const tags = issue.labels.map((l) => l.name);\n const author = issue.author?.login ?? \"ghost\";\n const comments = issue.comments.length;\n\n const base: SummaryItem = {\n number: issue.number,\n title: issue.title,\n tags,\n author,\n comments,\n age,\n lastComment: latestCommentAge(issue, now),\n updated: timeAgo(issue.updatedAt, now),\n };\n\n // Issues needing human attention are excluded from all actionable buckets\n if (hasExactLabel(issue.labels, \"needs:human\")) {\n return {\n bucket: \"needsHuman\",\n item: { ...base, assigned },\n };\n }\n\n // Bot governance labels (exact match)\n if (hasExactLabel(issue.labels, \"phase:voting\") || hasExactLabel(issue.labels, \"phase:extended-voting\")) {\n return { bucket: \"voteOn\", item: base };\n }\n if (hasExactLabel(issue.labels, \"phase:discussion\")) {\n return { bucket: \"discuss\", item: base };\n }\n if (hasExactLabel(issue.labels, \"phase:ready-to-implement\")) {\n return { bucket: \"implement\", item: { ...base, assigned } };\n }\n\n // Keyword fallback (repos without the bot)\n if (hasLabel(issue.labels, \"vote\")) {\n return { bucket: \"voteOn\", item: base };\n }\n if (hasLabel(issue.labels, \"discuss\")) {\n return { bucket: \"discuss\", item: base };\n }\n\n return {\n bucket: \"implement\",\n item: { ...base, assigned },\n };\n}\n\nfunction classifyPR(\n pr: GitHubPR,\n now: Date,\n): { bucket: \"reviewPRs\" | \"addressFeedback\"; item: SummaryItem } {\n const age = timeAgo(pr.createdAt, now);\n const tags = pr.labels.map((l) => l.name);\n const author = pr.author?.login ?? \"ghost\";\n const comments = pr.comments.length;\n const ciFailing = hasCIFailure(pr);\n const checks = compactChecks(checkStatus(pr));\n const merge = compactMergeable(mergeStatus(pr));\n const review = {\n approvals: approvalCount(pr),\n changesRequested: changesRequestedCount(pr),\n };\n\n if (pr.isDraft || ciFailing || pr.reviewDecision === \"CHANGES_REQUESTED\" || changesRequestedCount(pr) > 0) {\n let status: string;\n if (pr.isDraft) status = \"draft\";\n else if (pr.reviewDecision === \"CHANGES_REQUESTED\" || changesRequestedCount(pr) > 0) status = \"changes-requested\";\n else status = \"pending\";\n\n return {\n bucket: \"addressFeedback\",\n item: { number: pr.number, title: pr.title, tags, author, comments, age, status, checks, mergeable: merge, review },\n };\n }\n\n const status = pr.reviewDecision === \"APPROVED\" ? \"approved\" : \"pending\";\n\n return {\n bucket: \"reviewPRs\",\n item: { number: pr.number, title: pr.title, tags, author, comments, age, status, checks, mergeable: merge, review },\n };\n}\n\nfunction buildCompetitionMap(prs: GitHubPR[], currentUser: string): Map<number, number> {\n const map = new Map<number, number>();\n for (const pr of prs) {\n if (!hasLabel(pr.labels, \"implementation\")) continue;\n if (pr.author?.login === currentUser) continue;\n for (const ref of pr.closingIssuesReferences) {\n map.set(ref.number, (map.get(ref.number) ?? 0) + 1);\n }\n }\n return map;\n}\n\nexport function buildSummary(\n repo: RepoRef,\n issues: GitHubIssue[],\n prs: GitHubPR[],\n currentUser: string,\n now: Date = new Date(),\n): RepoSummary {\n const needsHuman: SummaryItem[] = [];\n const voteOn: SummaryItem[] = [];\n const discuss: SummaryItem[] = [];\n const implement: SummaryItem[] = [];\n const reviewPRs: SummaryItem[] = [];\n const addressFeedback: SummaryItem[] = [];\n\n for (const issue of issues) {\n const { bucket, item } = classifyIssue(issue, now);\n if (bucket === \"needsHuman\") needsHuman.push(item);\n else if (bucket === \"voteOn\") voteOn.push(item);\n else if (bucket === \"discuss\") discuss.push(item);\n else if (bucket === \"implement\") implement.push(item);\n }\n\n // Annotate implement items with competing PR counts\n const competitionMap = buildCompetitionMap(prs, currentUser);\n for (const item of implement) {\n const count = competitionMap.get(item.number) ?? 0;\n if (count > 0) {\n item.competingPRs = count;\n }\n }\n\n for (const pr of prs) {\n const { bucket, item } = classifyPR(pr, now);\n const ctx = reviewContext(pr, currentUser, now);\n if (ctx) {\n item.yourReview = ctx.yourReview;\n item.yourReviewAge = ctx.yourReviewAge;\n }\n item.lastCommit = latestCommitAge(pr, now);\n item.lastComment = latestCommentAge(pr, now);\n item.updated = timeAgo(pr.updatedAt, now);\n if (bucket === \"reviewPRs\") reviewPRs.push(item);\n else addressFeedback.push(item);\n }\n\n // Extract authored items into \"drive\" buckets so the agent knows what it owns\n const driveDiscussion: SummaryItem[] = [];\n const driveImplementation: SummaryItem[] = [];\n\n const filteredDiscuss = discuss.filter((item) => {\n if (item.author === currentUser) { driveDiscussion.push(item); return false; }\n return true;\n });\n\n const filteredVoteOn = voteOn.filter((item) => {\n if (item.author === currentUser && item.tags.includes(\"phase:extended-voting\")) {\n driveDiscussion.push(item);\n return false;\n }\n return true;\n });\n\n const filteredReviewPRs = reviewPRs.filter((item) => {\n if (item.author === currentUser) { driveImplementation.push(item); return false; }\n return true;\n });\n\n const filteredAddressFeedback = addressFeedback.filter((item) => {\n if (item.author === currentUser) { driveImplementation.push(item); return false; }\n return true;\n });\n\n return {\n repo,\n currentUser,\n needsHuman,\n driveDiscussion,\n driveImplementation,\n voteOn: filteredVoteOn,\n discuss: filteredDiscuss,\n implement,\n reviewPRs: filteredReviewPRs,\n addressFeedback: filteredAddressFeedback,\n notes: [],\n };\n}\n","import chalk from \"chalk\";\nimport type { RepoSummary, RoleConfig, SummaryItem, TeamConfig } from \"../config/types.js\";\n\nconst DIVIDER_WIDTH = 50;\n\n// Section types determine which metadata keys appear on the second line\ntype SectionType = \"vote\" | \"discuss\" | \"implement\" | \"reviewPRs\" | \"addressFeedback\" | \"driveDiscussion\" | \"driveImplementation\" | \"needsHuman\";\n\nfunction sectionDivider(title: string, count: number): string {\n const label = ` ${title} (${count}) `;\n const remaining = Math.max(0, DIVIDER_WIDTH - label.length - 2);\n return chalk.dim(\"──\") + chalk.bold(label) + chalk.dim(\"─\".repeat(remaining));\n}\n\nfunction formatTags(tags: string[]): string {\n if (tags.length === 0) return \"\";\n return \" \" + tags.map((t) => chalk.magenta(`[${t}]`)).join(\" \");\n}\n\nfunction kv(key: string, value: string | number): string {\n return `${key}: ${chalk.dim(String(value))}`;\n}\n\nfunction formatMeta(item: SummaryItem, sectionType: SectionType, currentUser: string): string {\n const isYou = item.author === currentUser;\n const authorVal = isYou ? chalk.green(`${item.author} (you)`) : chalk.dim(item.author);\n const parts: string[] = [`by: ${authorVal}`];\n\n if (sectionType === \"implement\" || sectionType === \"needsHuman\") {\n parts.push(kv(\"assigned\", item.assigned ?? \"--\"));\n parts.push(kv(\"comments\", item.comments));\n if (item.lastComment) parts.push(kv(\"last-comment\", item.lastComment));\n if (item.updated) parts.push(kv(\"updated\", item.updated));\n parts.push(kv(\"created\", item.age));\n if (item.competingPRs !== undefined) {\n parts.push(kv(\"competing\", item.competingPRs));\n }\n } else if (sectionType === \"vote\" || sectionType === \"discuss\" || sectionType === \"driveDiscussion\") {\n parts.push(kv(\"comments\", item.comments));\n if (item.lastComment) parts.push(kv(\"last-comment\", item.lastComment));\n if (item.updated) parts.push(kv(\"updated\", item.updated));\n parts.push(kv(\"created\", item.age));\n } else {\n // PR sections: reviewPRs, addressFeedback, driveImplementation\n if (item.status !== undefined) {\n const statusVal = /changes.requested/i.test(item.status) ? chalk.red(item.status) : chalk.dim(item.status);\n parts.push(`status: ${statusVal}`);\n }\n if (item.checks !== undefined && item.checks !== null) {\n const checksVal = /fail/i.test(item.checks) ? chalk.red(item.checks) : chalk.dim(item.checks);\n parts.push(`checks: ${checksVal}`);\n }\n if (item.mergeable !== undefined && item.mergeable !== null) {\n const mergeVal = /conflict/i.test(item.mergeable) ? chalk.red(item.mergeable) : chalk.dim(item.mergeable);\n parts.push(`merge: ${mergeVal}`);\n }\n if (item.review) {\n const segments = [`${item.review.approvals} approved`];\n if (item.review.changesRequested > 0) segments.push(chalk.red(`${item.review.changesRequested} changes-requested`));\n parts.push(kv(\"review\", segments.join(\", \")));\n }\n if (item.yourReview) {\n const age = item.yourReviewAge ? ` (${item.yourReviewAge})` : \"\";\n parts.push(kv(\"you\", `${item.yourReview}${age}`));\n }\n if (item.lastCommit) parts.push(kv(\"last-commit\", item.lastCommit));\n if (item.lastComment) parts.push(kv(\"last-comment\", item.lastComment));\n if (item.updated) parts.push(kv(\"updated\", item.updated));\n parts.push(kv(\"comments\", item.comments));\n parts.push(kv(\"created\", item.age));\n }\n\n return parts.join(\" \");\n}\n\nfunction formatItem(item: SummaryItem, currentUser: string, sectionType: SectionType): string {\n const isYou = item.author === currentUser;\n const prefix = isYou ? chalk.green(\"★\") : \" \";\n const num = chalk.cyan(`#${item.number}`);\n const tags = formatTags(item.tags);\n const hasProblems = (item.checks && /fail/i.test(item.checks)) || (item.mergeable && /conflict/i.test(item.mergeable));\n const warningIcon = hasProblems ? \" \" + chalk.red(\"✗\") : \"\";\n\n const titleLine = `${prefix} ${num} ${item.title}${tags}${warningIcon}`;\n const metaLine = ` ${formatMeta(item, sectionType, currentUser)}`;\n\n return `${titleLine}\\n${metaLine}`;\n}\n\nfunction formatSection(\n title: string,\n items: SummaryItem[],\n currentUser: string,\n sectionType: SectionType,\n limit?: number,\n): string {\n if (items.length === 0) return \"\";\n\n const displayed = limit ? items.slice(0, limit) : items;\n const header = sectionDivider(title, items.length);\n const itemBlocks = displayed.map((item) => formatItem(item, currentUser, sectionType));\n\n const parts = [header, ...itemBlocks];\n\n if (limit && items.length > limit) {\n parts.push(chalk.dim(` ... and ${items.length - limit} more`));\n }\n\n return parts.join(\"\\n\\n\");\n}\n\nfunction formatSummaryBody(summary: RepoSummary, limit?: number): string {\n const u = summary.currentUser;\n const sections: string[] = [];\n\n sections.push(\n ...[\n formatSection(\"NEEDS HUMAN\", summary.needsHuman, u, \"needsHuman\", limit),\n formatSection(\"DRIVE THE DISCUSSION\", summary.driveDiscussion, u, \"driveDiscussion\", limit),\n formatSection(\"DRIVE THE IMPLEMENTATION\", summary.driveImplementation, u, \"driveImplementation\", limit),\n formatSection(\"VOTE ON ISSUES\", summary.voteOn, u, \"vote\", limit),\n formatSection(\"DISCUSS ISSUES\", summary.discuss, u, \"discuss\", limit),\n formatSection(\"READY TO IMPLEMENT ISSUES\", summary.implement, u, \"implement\", limit),\n formatSection(\"REVIEW PRs\", summary.reviewPRs, u, \"reviewPRs\", limit),\n formatSection(\"ADDRESS FEEDBACK PRs\", summary.addressFeedback, u, \"addressFeedback\", limit),\n ].filter(Boolean),\n );\n\n if (summary.notes.length > 0) {\n sections.push(summary.notes.map((n) => chalk.dim(` ${n}`)).join(\"\\n\"));\n }\n\n if (sections.length === 0) {\n return chalk.dim(\" No open issues or PRs.\");\n }\n\n return sections.join(\"\\n\\n\");\n}\n\nexport function formatBuzz(\n roleName: string,\n role: RoleConfig,\n summary: RepoSummary,\n limit?: number,\n): string {\n const lines = [\n chalk.bold(`ROLE: ${roleName}`) + ` — ${role.description}`,\n \"\",\n chalk.bold(\"INSTRUCTIONS:\"),\n role.instructions.trimEnd(),\n \"\",\n summary.currentUser\n ? `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}, logged in as ${chalk.green(summary.currentUser)}`\n : `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}`,\n \"\",\n formatSummaryBody(summary, limit),\n ];\n\n return lines.join(\"\\n\");\n}\n\nexport function formatStatus(summary: RepoSummary, limit?: number): string {\n const lines = [\n summary.currentUser\n ? `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}, logged in as ${chalk.green(summary.currentUser)}`\n : `You are working on ${chalk.bold(`${summary.repo.owner}/${summary.repo.repo}`)}`,\n \"\",\n formatSummaryBody(summary, limit),\n ];\n\n return lines.join(\"\\n\");\n}\n\nexport function formatRoles(teamConfig: TeamConfig, repoFullName: string): string {\n const nameLabel = teamConfig.name ? ` (${teamConfig.name})` : \"\";\n const lines = [\n chalk.bold(`ROLES — ${repoFullName}${nameLabel}`),\n \"\",\n ];\n\n const slugs = Object.keys(teamConfig.roles);\n const maxLen = Math.max(...slugs.map((s) => s.length));\n\n for (const slug of slugs) {\n const role = teamConfig.roles[slug];\n const padded = slug.padEnd(maxLen + 2);\n lines.push(` ${chalk.cyan(padded)}${role.description}`);\n }\n\n return lines.join(\"\\n\");\n}\n","import type { RepoSummary, RoleConfig, TeamConfig } from \"../config/types.js\";\n\nexport function jsonBuzz(\n roleName: string,\n role: RoleConfig,\n summary: RepoSummary,\n): string {\n return JSON.stringify(\n {\n role: {\n name: roleName,\n description: role.description,\n instructions: role.instructions,\n },\n summary: {\n repo: `${summary.repo.owner}/${summary.repo.repo}`,\n currentUser: summary.currentUser,\n driveDiscussion: summary.driveDiscussion,\n driveImplementation: summary.driveImplementation,\n voteOn: summary.voteOn,\n discuss: summary.discuss,\n implement: summary.implement,\n reviewPRs: summary.reviewPRs,\n addressFeedback: summary.addressFeedback,\n needsHuman: summary.needsHuman,\n notes: summary.notes,\n },\n },\n null,\n 2,\n );\n}\n\nexport function jsonStatus(summary: RepoSummary): string {\n return JSON.stringify(\n {\n repo: `${summary.repo.owner}/${summary.repo.repo}`,\n currentUser: summary.currentUser,\n driveDiscussion: summary.driveDiscussion,\n driveImplementation: summary.driveImplementation,\n voteOn: summary.voteOn,\n discuss: summary.discuss,\n implement: summary.implement,\n reviewPRs: summary.reviewPRs,\n addressFeedback: summary.addressFeedback,\n needsHuman: summary.needsHuman,\n notes: summary.notes,\n },\n null,\n 2,\n );\n}\n\nexport function jsonRoles(teamConfig: TeamConfig): string {\n const roles = Object.entries(teamConfig.roles).map(([slug, role]) => ({\n name: slug,\n description: role.description,\n }));\n\n return JSON.stringify({ roles }, null, 2);\n}\n","import { CliError, type BuzzOptions } from \"../config/types.js\";\nimport { loadTeamConfig } from \"../config/loader.js\";\nimport { resolveRepo } from \"../github/repo.js\";\nimport { fetchIssues } from \"../github/issues.js\";\nimport { fetchPulls } from \"../github/pulls.js\";\nimport { fetchCurrentUser } from \"../github/user.js\";\nimport { buildSummary } from \"../summary/builder.js\";\nimport { formatBuzz, formatStatus } from \"../output/formatter.js\";\nimport { jsonBuzz, jsonStatus } from \"../output/json.js\";\n\nfunction errorDetail(reason: unknown): string {\n return reason instanceof Error ? reason.message : String(reason);\n}\n\nexport async function buzzCommand(options: BuzzOptions): Promise<void> {\n const repo = await resolveRepo(options.repo);\n const fetchLimit = options.fetchLimit ?? 200;\n\n const [issuesResult, prsResult, userResult] = await Promise.allSettled([\n fetchIssues(repo, fetchLimit),\n fetchPulls(repo, fetchLimit),\n fetchCurrentUser(),\n ]);\n\n // If all three failed, surface the most actionable CliError.\n if (\n issuesResult.status === \"rejected\" &&\n prsResult.status === \"rejected\" &&\n userResult.status === \"rejected\"\n ) {\n const cliErrors = [issuesResult, prsResult, userResult]\n .map((r) => r.reason)\n .filter((r): r is CliError => r instanceof CliError);\n const actionableCodes = [\"GH_NOT_AUTHENTICATED\", \"RATE_LIMITED\", \"GH_NOT_FOUND\"];\n const best = cliErrors.find((e) => actionableCodes.includes(e.code)) ?? cliErrors[0];\n throw best ?? issuesResult.reason;\n }\n\n const issues = issuesResult.status === \"fulfilled\" ? issuesResult.value : [];\n const prs = prsResult.status === \"fulfilled\" ? prsResult.value : [];\n const currentUser = userResult.status === \"fulfilled\" ? userResult.value : \"\";\n\n const summary = buildSummary(repo, issues, prs, currentUser);\n\n if (issuesResult.status === \"rejected\" && prsResult.status === \"rejected\") {\n summary.notes.push(\n `Could not fetch issues (${errorDetail(issuesResult.reason)}) or pull requests (${errorDetail(prsResult.reason)}) — showing limited summary.`,\n );\n } else if (issuesResult.status === \"rejected\") {\n summary.notes.push(`Could not fetch issues (${errorDetail(issuesResult.reason)}) — showing PRs only.`);\n } else if (prsResult.status === \"rejected\") {\n summary.notes.push(`Could not fetch pull requests (${errorDetail(prsResult.reason)}) — showing issues only.`);\n }\n\n if (userResult.status === \"rejected\") {\n summary.notes.push(\n `Could not determine GitHub user (${errorDetail(userResult.reason)}) — drive sections, competition counts, and author highlighting are unavailable.`,\n );\n }\n\n if (issues.length >= fetchLimit) {\n summary.notes.push(`Only the first ${fetchLimit} issues were fetched. Use --fetch-limit to increase.`);\n }\n if (prs.length >= fetchLimit) {\n summary.notes.push(`Only the first ${fetchLimit} PRs were fetched. Use --fetch-limit to increase.`);\n }\n\n if (options.role) {\n const teamConfig = await loadTeamConfig(repo);\n if (!Object.hasOwn(teamConfig.roles, options.role)) {\n const available = Object.keys(teamConfig.roles).join(\", \");\n throw new CliError(\n `Role '${options.role}' not found. Available: ${available}. Run: hivemoot roles`,\n \"ROLE_NOT_FOUND\",\n 1,\n );\n }\n const roleConfig = teamConfig.roles[options.role];\n\n if (options.json) {\n console.log(jsonBuzz(options.role, roleConfig, summary));\n } else {\n console.log(formatBuzz(options.role, roleConfig, summary, options.limit));\n }\n } else {\n if (options.json) {\n console.log(jsonStatus(summary));\n } else {\n console.log(formatStatus(summary, options.limit));\n }\n }\n}\n","import type { RolesOptions } from \"../config/types.js\";\nimport { loadTeamConfig } from \"../config/loader.js\";\nimport { resolveRepo } from \"../github/repo.js\";\nimport { formatRoles } from \"../output/formatter.js\";\nimport { jsonRoles } from \"../output/json.js\";\n\nexport async function rolesCommand(options: RolesOptions): Promise<void> {\n const repo = await resolveRepo(options.repo);\n const teamConfig = await loadTeamConfig(repo);\n\n if (options.json) {\n console.log(jsonRoles(teamConfig));\n } else {\n console.log(formatRoles(teamConfig, `${repo.owner}/${repo.repo}`));\n }\n}\n","export async function initCommand(): Promise<void> {\n const template = `# Hivemoot team configuration\n# Place this file at .github/hivemoot.yml in your repository.\n#\n# Roles define personas (who the agent is), not workflow.\n# Workflow details belong in .agent/skills/.\n\nteam:\n roles:\n pm:\n description: \"Product manager focused on user value and clarity\"\n instructions: |\n You think from the user's perspective.\n Evaluate ideas by the problem they solve and who benefits.\n Push for clear requirements and well-scoped proposals.\n Ask \"why does this matter?\" before \"how do we build it?\"\n\n engineer:\n description: \"Software engineer focused on clean implementation\"\n instructions: |\n You care about code quality, patterns, and maintainability.\n Favor simple, proven approaches over clever solutions.\n Write clean code with good test coverage.\n Build on existing conventions in the codebase.\n\n architect:\n description: \"Architect focused on system design and long-term health\"\n instructions: |\n You think about how pieces fit together.\n Evaluate proposals for scalability, consistency, and technical debt.\n Guard the system's boundaries and abstractions.\n Push back when short-term wins create long-term problems.\n\n qa:\n description: \"QA engineer focused on reliability and edge cases\"\n instructions: |\n You think about what can go wrong.\n Find edge cases, race conditions, and failure modes others miss.\n Push for thorough error handling and defensive design.\n Ask \"what happens when this fails?\" about everything.\n`;\n\n console.log(template);\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,4BAA4B;;;ACiJvC,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACE,SACgB,MACA,WAAmB,GACnC;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;AC3JA,OAAO,UAAU;;;ACAjB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,IAAM,gBAAgB,UAAU,QAAQ;AAExC,IAAI;AAGG,SAAS,WAAW,OAAqB;AAC9C,YAAU;AACZ;AAMA,eAAsB,GAAG,MAAiC;AACxD,MAAI;AACF,UAAM,OAAqD;AAAA,MACzD,SAAS;AAAA,IACX;AACA,QAAI,SAAS;AACX,WAAK,MAAM,EAAE,GAAG,QAAQ,KAAK,UAAU,QAAQ;AAAA,IACjD;AACA,UAAM,EAAE,OAAO,IAAI,MAAM,cAAc,MAAM,MAAM,IAAI;AACvD,WAAO,OAAO,KAAK;AAAA,EACrB,SAAS,KAAc;AACrB,UAAM,QAAQ;AAKd,QAAI,MAAM,SAAS,UAAU;AAC3B,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,UAAU,MAAM,WAAW;AAEhD,QAAI,uDAAuD,KAAK,MAAM,GAAG;AACvE,YAAM,IAAI;AAAA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