opencode-forgekeeper 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -825
- package/dist/index.js +1838 -770
- package/dist/tui.js +95 -6
- 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 =
|
|
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,6 +814,7 @@ 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} }
|
|
@@ -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);
|
|
@@ -1074,6 +1085,7 @@ class GitLabForge {
|
|
|
1074
1085
|
...node.sourceProject ? { sourceProject: node.sourceProject.fullPath } : {},
|
|
1075
1086
|
sourceBranch: node.sourceBranch,
|
|
1076
1087
|
headSha: node.diffHeadSha ?? undefined,
|
|
1088
|
+
...node.author?.id ? { authorID: node.author.id } : {},
|
|
1077
1089
|
updatedAt: node.updatedAt ?? undefined,
|
|
1078
1090
|
pipeline: pipeline ? {
|
|
1079
1091
|
status: pipeline.status,
|
|
@@ -1092,6 +1104,7 @@ class GitLabForge {
|
|
|
1092
1104
|
var COPILOT_AUTHOR = "copilot-pull-request-reviewer[bot]";
|
|
1093
1105
|
var fields = `number title url state isDraft mergeable reviewDecision headRefOid headRefName
|
|
1094
1106
|
headRepository { nameWithOwner } baseRepository { nameWithOwner } baseRefName updatedAt
|
|
1107
|
+
author { ... on User { id } ... on Bot { id } }
|
|
1095
1108
|
reviewThreads(first:100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
|
|
1096
1109
|
reviewRequests(first:100) { nodes { requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { name } } } pageInfo { hasNextPage endCursor } }
|
|
1097
1110
|
copilotReviews: reviews(last:1, author:"${COPILOT_AUTHOR}", states:[COMMENTED,CHANGES_REQUESTED,APPROVED,DISMISSED]) { nodes { id state comments { totalCount } } }
|
|
@@ -1216,6 +1229,17 @@ var githubTraits = {
|
|
|
1216
1229
|
status: (request) => copilotStatus(request.copilotReview)
|
|
1217
1230
|
},
|
|
1218
1231
|
feedback: {
|
|
1232
|
+
async viewerID(run, directory, host) {
|
|
1233
|
+
const data = await typed(ghGraphQL(run, directory))(host, query("query { viewer { id } }"), {});
|
|
1234
|
+
return data.viewer?.id;
|
|
1235
|
+
},
|
|
1236
|
+
async reviewerID(run, directory, host, username) {
|
|
1237
|
+
const result = await run("gh", ["api", "--hostname", host, `users/${encodeURIComponent(username)}`], directory);
|
|
1238
|
+
if (result.code !== 0)
|
|
1239
|
+
throw new Error("Could not resolve the GitHub reviewer account");
|
|
1240
|
+
const user = JSON.parse(result.stdout);
|
|
1241
|
+
return user.login?.toLowerCase() === username.toLowerCase() ? user.node_id : undefined;
|
|
1242
|
+
},
|
|
1219
1243
|
async fetch(run, directory, request) {
|
|
1220
1244
|
const ref = githubTraits.parseUrl(request.url);
|
|
1221
1245
|
return ref ? fetchComments(ghGraphQL(run, directory), ref.host, ref.project, ref.iid) : undefined;
|
|
@@ -1418,6 +1442,7 @@ class GitHubForge {
|
|
|
1418
1442
|
...node.headRepository ? { sourceProject: node.headRepository.nameWithOwner } : {},
|
|
1419
1443
|
sourceBranch: node.headRefName,
|
|
1420
1444
|
headSha: node.headRefOid,
|
|
1445
|
+
...node.author?.id ? { authorID: node.author.id } : {},
|
|
1421
1446
|
updatedAt: node.updatedAt,
|
|
1422
1447
|
pipeline: contexts.nodes.length || !contexts.complete ? checks(contexts.nodes, contexts.complete, `${node.url}/checks`, node.headRefOid) : undefined,
|
|
1423
1448
|
unresolvedThreads: threads.unresolved,
|
|
@@ -1744,6 +1769,15 @@ var ForgeSessionRpc = {
|
|
|
1744
1769
|
},
|
|
1745
1770
|
output: inboxState
|
|
1746
1771
|
},
|
|
1772
|
+
actOnFeedback: {
|
|
1773
|
+
input: {
|
|
1774
|
+
type: "object",
|
|
1775
|
+
properties: { id: { type: "string" }, retry: { type: "boolean" } },
|
|
1776
|
+
required: ["id"],
|
|
1777
|
+
additionalProperties: false
|
|
1778
|
+
},
|
|
1779
|
+
output: inboxState
|
|
1780
|
+
},
|
|
1747
1781
|
target: {
|
|
1748
1782
|
input: {
|
|
1749
1783
|
type: "object",
|
|
@@ -2678,10 +2712,65 @@ var tui_default = {
|
|
|
2678
2712
|
title: `Review feedback and PR/MR updates${state.paused ? " (monitoring paused)" : ""}`,
|
|
2679
2713
|
options: state.items.map((item2) => ({
|
|
2680
2714
|
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 "),
|
|
2715
|
+
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
2716
|
value: item2.id
|
|
2683
2717
|
})),
|
|
2684
2718
|
actions: [{
|
|
2719
|
+
bind: "ctrl+a",
|
|
2720
|
+
title: "Act on feedback",
|
|
2721
|
+
onTrigger: async (id) => {
|
|
2722
|
+
try {
|
|
2723
|
+
await rpc.actOnFeedback({
|
|
2724
|
+
id
|
|
2725
|
+
}, {
|
|
2726
|
+
location: {
|
|
2727
|
+
directory
|
|
2728
|
+
}
|
|
2729
|
+
});
|
|
2730
|
+
context.ui.dialog.clear();
|
|
2731
|
+
showFeedback();
|
|
2732
|
+
} catch (error) {
|
|
2733
|
+
context.ui.toast.show({
|
|
2734
|
+
message: String(error),
|
|
2735
|
+
variant: "error"
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
}, {
|
|
2740
|
+
bind: "ctrl+t",
|
|
2741
|
+
title: "Retry feedback work",
|
|
2742
|
+
onTrigger: async (id) => {
|
|
2743
|
+
const confirmed = await context.ui.dialog.select({
|
|
2744
|
+
title: "Retry may repeat earlier changes. Inspect the session first.",
|
|
2745
|
+
options: [{
|
|
2746
|
+
title: "Cancel",
|
|
2747
|
+
value: "cancel"
|
|
2748
|
+
}, {
|
|
2749
|
+
title: "Retry feedback work",
|
|
2750
|
+
value: "retry"
|
|
2751
|
+
}]
|
|
2752
|
+
});
|
|
2753
|
+
if (confirmed !== "retry")
|
|
2754
|
+
return;
|
|
2755
|
+
try {
|
|
2756
|
+
await rpc.actOnFeedback({
|
|
2757
|
+
id,
|
|
2758
|
+
retry: true
|
|
2759
|
+
}, {
|
|
2760
|
+
location: {
|
|
2761
|
+
directory
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2764
|
+
context.ui.dialog.clear();
|
|
2765
|
+
showFeedback();
|
|
2766
|
+
} catch (error) {
|
|
2767
|
+
context.ui.toast.show({
|
|
2768
|
+
message: String(error),
|
|
2769
|
+
variant: "error"
|
|
2770
|
+
});
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
}, {
|
|
2685
2774
|
bind: "ctrl+d",
|
|
2686
2775
|
title: "Acknowledge",
|
|
2687
2776
|
onTrigger: async (id) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-forgekeeper",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.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",
|