opencode-forgekeeper 3.0.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +32 -8
  2. package/dist/index.js +2143 -862
  3. package/dist/tui.js +106 -9
  4. package/package.json +1 -1
package/dist/tui.js CHANGED
@@ -273,10 +273,10 @@ async function readOlderComments(graphql, host, thread) {
273
273
  var detailsQuery = (ids) => query(`query {
274
274
  nodes(ids: ${JSON.stringify(ids)}) {
275
275
  __typename
276
- ... on IssueComment { id url body author { login } }
277
- ... on PullRequestReview { id url body author { login } }
276
+ ... on IssueComment { id url body author { login ... on User { id } ... on Bot { id } } }
277
+ ... on PullRequestReview { id url body author { login ... on User { id } ... on Bot { id } } }
278
278
  ... on PullRequestReviewComment {
279
- id url body path line originalLine diffHunk author { login }
279
+ id url body path line originalLine diffHunk author { login ... on User { id } ... on Bot { id } }
280
280
  replyTo { body author { login } }
281
281
  }
282
282
  }
@@ -301,6 +301,7 @@ async function fetchDetails(transport, host, ids) {
301
301
  id: node.id,
302
302
  url: node.url,
303
303
  username: node.author.login,
304
+ ...node.author.id ? { authorID: node.author.id } : {},
304
305
  body: node.body,
305
306
  ...node.path ? { path: node.path } : {},
306
307
  ...line !== undefined ? { line } : {},
@@ -456,7 +457,7 @@ async function fetchDetails2(transport, host, project, ids) {
456
457
  const nodes = [];
457
458
  const numeric = ids.filter((id) => /^\d+$/.test(id));
458
459
  for (let start = 0;start < numeric.length; start += DETAIL_BATCH2) {
459
- const fields = numeric.slice(start, start + DETAIL_BATCH2).map((id, index) => `n${index}: note(id: "gid://gitlab/Note/${id}") { id url body author { username }
460
+ const fields = numeric.slice(start, start + DETAIL_BATCH2).map((id, index) => `n${index}: note(id: "gid://gitlab/Note/${id}") { id url body author { id username }
460
461
  position { diffRefs { baseSha headSha } newPath newLine oldPath oldLine }
461
462
  discussion { notes(first: ${THREAD_NOTES}) { nodes { id body author { username } } } } }`).join(`
462
463
  `);
@@ -477,6 +478,7 @@ async function fetchDetails2(transport, host, project, ids) {
477
478
  id: noteNumber(node.id),
478
479
  url: node.url ?? "",
479
480
  username: node.author?.username ?? "",
481
+ ...node.author?.id ? { authorID: node.author.id } : {},
480
482
  body: node.body,
481
483
  ...at ? { path: at.path, line: at.line } : {},
482
484
  ...text && at ? { code: { path: at.path, text } } : {},
@@ -586,7 +588,7 @@ async function fetchLinkedNote(transport, host, url) {
586
588
  }
587
589
 
588
590
  // packages/forgekeeper/src/human-review-watch.ts
589
- var SETTLE_TIME = 5 * 60000;
591
+ var SETTLE_TIME = 4 * 60000;
590
592
  var RETRY_DELAY = 10 * 60000;
591
593
  var RECORD_RETENTION = 30 * 24 * 60 * 60000;
592
594
  var TOUCH_INTERVAL = 24 * 60 * 60000;
@@ -812,11 +814,12 @@ var MERGE_REQUEST_FIELDS = `
812
814
  approvedBy(first: 100) { nodes { id bot } }
813
815
  sourceProject { fullPath }
814
816
  targetProject { fullPath }
817
+ author { id }
815
818
  headPipeline {
816
819
  id status path detailedStatus { label }
817
820
  jobs(statuses: [FAILED], retried: false, first: ${FIRST_FAILED_JOBS}) { ${FAILED_JOBS} }
818
821
  }
819
- reviewers(first: 100) { nodes { type username bot mergeRequestInteraction { reviewState approved } } }
822
+ reviewers(first: 100) { nodes { id type username bot mergeRequestInteraction { reviewState approved } } }
820
823
  discussions(first: ${PAGE_SIZE3}) { ${DISCUSSIONS} }
821
824
  `;
822
825
  function mergeRequestsQuery(projectCount) {
@@ -925,6 +928,14 @@ var gitlabTraits = {
925
928
  }
926
929
  },
927
930
  feedback: {
931
+ async viewerID(run, directory, host) {
932
+ const data = await typed(glabGraphQL(run, directory))(host, query("query { currentUser { id } }"), {});
933
+ return data.currentUser?.id;
934
+ },
935
+ async reviewerID(run, directory, host, username) {
936
+ const data = await typed(glabGraphQL(run, directory))(host, query("query($username: String!) { user(username: $username) { id username } }"), { username });
937
+ return data.user?.username.toLowerCase() === username.toLowerCase() ? data.user.id : undefined;
938
+ },
928
939
  subscribe: subscribeToNotes,
929
940
  async fetch(run, directory, request) {
930
941
  const ref = gitlabTraits.parseUrl(request.url);
@@ -1068,12 +1079,14 @@ class GitLabForge {
1068
1079
  approvalRequirementsSatisfied: node.approved,
1069
1080
  awaitingReviewers,
1070
1081
  reviewersComplete: true,
1082
+ reviewerIDs: (node.reviewers?.nodes ?? []).flatMap((reviewer) => reviewer.id ?? []),
1071
1083
  mergeStatus: node.detailedMergeStatus ?? undefined,
1072
1084
  targetProject: node.targetProject.fullPath,
1073
1085
  targetBranch: node.targetBranch,
1074
1086
  ...node.sourceProject ? { sourceProject: node.sourceProject.fullPath } : {},
1075
1087
  sourceBranch: node.sourceBranch,
1076
1088
  headSha: node.diffHeadSha ?? undefined,
1089
+ ...node.author?.id ? { authorID: node.author.id } : {},
1077
1090
  updatedAt: node.updatedAt ?? undefined,
1078
1091
  pipeline: pipeline ? {
1079
1092
  status: pipeline.status,
@@ -1092,8 +1105,10 @@ class GitLabForge {
1092
1105
  var COPILOT_AUTHOR = "copilot-pull-request-reviewer[bot]";
1093
1106
  var fields = `number title url state isDraft mergeable reviewDecision headRefOid headRefName
1094
1107
  headRepository { nameWithOwner } baseRepository { nameWithOwner } baseRefName updatedAt
1108
+ author { ... on User { id } ... on Bot { id } }
1095
1109
  reviewThreads(first:100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
1096
- reviewRequests(first:100) { nodes { requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { name } } } pageInfo { hasNextPage endCursor } }
1110
+ reviewRequests(first:100) { nodes { requestedReviewer { __typename ... on User { id login } ... on Bot { login } ... on Team { name } } } pageInfo { hasNextPage endCursor } }
1111
+ latestReviews(first:100) { nodes { author { ... on User { id } } } }
1097
1112
  copilotReviews: reviews(last:1, author:"${COPILOT_AUTHOR}", states:[COMMENTED,CHANGES_REQUESTED,APPROVED,DISMISSED]) { nodes { id state comments { totalCount } } }
1098
1113
  commits(last:1) { nodes { commit { statusCheckRollup { contexts(first:100) {
1099
1114
  nodes { __typename ... on CheckRun { id name status conclusion detailsUrl } ... on StatusContext { id context state targetUrl } }
@@ -1216,6 +1231,17 @@ var githubTraits = {
1216
1231
  status: (request) => copilotStatus(request.copilotReview)
1217
1232
  },
1218
1233
  feedback: {
1234
+ async viewerID(run, directory, host) {
1235
+ const data = await typed(ghGraphQL(run, directory))(host, query("query { viewer { id } }"), {});
1236
+ return data.viewer?.id;
1237
+ },
1238
+ async reviewerID(run, directory, host, username) {
1239
+ const result = await run("gh", ["api", "--hostname", host, `users/${encodeURIComponent(username)}`], directory);
1240
+ if (result.code !== 0)
1241
+ throw new Error("Could not resolve the GitHub reviewer account");
1242
+ const user = JSON.parse(result.stdout);
1243
+ return user.login?.toLowerCase() === username.toLowerCase() ? user.node_id : undefined;
1244
+ },
1219
1245
  async fetch(run, directory, request) {
1220
1246
  const ref = githubTraits.parseUrl(request.url);
1221
1247
  return ref ? fetchComments(ghGraphQL(run, directory), ref.host, ref.project, ref.iid) : undefined;
@@ -1376,7 +1402,7 @@ class GitHubForge {
1376
1402
  const data = await this.graphql(host, query(`query($owner:String!,$repo:String!,$number:Int!,$after:String!) {
1377
1403
  repository(owner:$owner,name:$repo) { pullRequest(number:$number) {
1378
1404
  reviewRequests(first:100,after:$after) {
1379
- nodes { requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { name } } }
1405
+ nodes { requestedReviewer { __typename ... on User { id login } ... on Bot { login } ... on Team { name } } }
1380
1406
  pageInfo { hasNextPage endCursor }
1381
1407
  }
1382
1408
  } }
@@ -1413,11 +1439,18 @@ class GitHubForge {
1413
1439
  return reviewer?.login ? [reviewer.login] : reviewer?.name ? [reviewer.name] : [];
1414
1440
  }),
1415
1441
  reviewersComplete: !reviewers.pageInfo?.hasNextPage,
1442
+ reviewerIDs: [
1443
+ ...new Set([
1444
+ ...reviewers.nodes.flatMap((request) => request.requestedReviewer?.__typename === "User" ? request.requestedReviewer.id ?? [] : []),
1445
+ ...(node.latestReviews?.nodes ?? []).flatMap((review) => review?.author?.id ?? [])
1446
+ ])
1447
+ ],
1416
1448
  targetProject: node.baseRepository.nameWithOwner,
1417
1449
  targetBranch: node.baseRefName,
1418
1450
  ...node.headRepository ? { sourceProject: node.headRepository.nameWithOwner } : {},
1419
1451
  sourceBranch: node.headRefName,
1420
1452
  headSha: node.headRefOid,
1453
+ ...node.author?.id ? { authorID: node.author.id } : {},
1421
1454
  updatedAt: node.updatedAt,
1422
1455
  pipeline: contexts.nodes.length || !contexts.complete ? checks(contexts.nodes, contexts.complete, `${node.url}/checks`, node.headRefOid) : undefined,
1423
1456
  unresolvedThreads: threads.unresolved,
@@ -1744,6 +1777,15 @@ var ForgeSessionRpc = {
1744
1777
  },
1745
1778
  output: inboxState
1746
1779
  },
1780
+ actOnFeedback: {
1781
+ input: {
1782
+ type: "object",
1783
+ properties: { id: { type: "string" }, retry: { type: "boolean" } },
1784
+ required: ["id"],
1785
+ additionalProperties: false
1786
+ },
1787
+ output: inboxState
1788
+ },
1747
1789
  target: {
1748
1790
  input: {
1749
1791
  type: "object",
@@ -2678,10 +2720,65 @@ var tui_default = {
2678
2720
  title: `Review feedback and PR/MR updates${state.paused ? " (monitoring paused)" : ""}`,
2679
2721
  options: state.items.map((item2) => ({
2680
2722
  title: item2.title,
2681
- description: [context.data.session.get(item2.sessionID)?.title ?? item2.sessionID, feedbackTime(item2), ...item2.details?.length ? [`${item2.details[0]}${item2.details.length > 1 ? ` (+${item2.details.length - 1})` : ""}`] : []].join(" \xB7 "),
2723
+ description: [context.data.session.get(item2.sessionID)?.title ?? item2.sessionID, feedbackTime(item2), ...item2.automation ? [`${item2.automation.state}${item2.automation.reason ? `: ${item2.automation.reason}` : ""}`] : [], ...item2.details?.length ? [`${item2.details[0]}${item2.details.length > 1 ? ` (+${item2.details.length - 1})` : ""}`] : []].join(" \xB7 "),
2682
2724
  value: item2.id
2683
2725
  })),
2684
2726
  actions: [{
2727
+ bind: "ctrl+a",
2728
+ title: "Act on feedback",
2729
+ onTrigger: async (id) => {
2730
+ try {
2731
+ await rpc.actOnFeedback({
2732
+ id
2733
+ }, {
2734
+ location: {
2735
+ directory
2736
+ }
2737
+ });
2738
+ context.ui.dialog.clear();
2739
+ showFeedback();
2740
+ } catch (error) {
2741
+ context.ui.toast.show({
2742
+ message: String(error),
2743
+ variant: "error"
2744
+ });
2745
+ }
2746
+ }
2747
+ }, {
2748
+ bind: "ctrl+t",
2749
+ title: "Retry feedback work",
2750
+ onTrigger: async (id) => {
2751
+ const confirmed = await context.ui.dialog.select({
2752
+ title: "Retry may repeat earlier changes. Inspect the session first.",
2753
+ options: [{
2754
+ title: "Cancel",
2755
+ value: "cancel"
2756
+ }, {
2757
+ title: "Retry feedback work",
2758
+ value: "retry"
2759
+ }]
2760
+ });
2761
+ if (confirmed !== "retry")
2762
+ return;
2763
+ try {
2764
+ await rpc.actOnFeedback({
2765
+ id,
2766
+ retry: true
2767
+ }, {
2768
+ location: {
2769
+ directory
2770
+ }
2771
+ });
2772
+ context.ui.dialog.clear();
2773
+ showFeedback();
2774
+ } catch (error) {
2775
+ context.ui.toast.show({
2776
+ message: String(error),
2777
+ variant: "error"
2778
+ });
2779
+ }
2780
+ }
2781
+ }, {
2685
2782
  bind: "ctrl+d",
2686
2783
  title: "Acknowledge",
2687
2784
  onTrigger: async (id) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-forgekeeper",
3
- "version": "3.0.2",
3
+ "version": "3.2.0",
4
4
  "description": "OpenCode plugin that tracks each session's GitHub and GitLab issues and PRs/MRs: title prefixes, a PR/MR status footer, and review notifications",
5
5
  "author": {
6
6
  "name": "Pedro Pombeiro",