pr-shepherd 1.5.0 → 1.6.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/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -0
- package/bin/api.d.mts +1 -1
- package/bin/commands/iterate/index.mjs +4 -0
- package/bin/commands/poll-events.d.mts +44 -0
- package/bin/commands/poll-events.mjs +123 -0
- package/bin/commands/poll-options.d.mts +9 -0
- package/bin/commands/poll-options.mjs +1 -0
- package/bin/commands/poll-progress.d.mts +2 -0
- package/bin/commands/poll-progress.mjs +6 -4
- package/bin/commands/poll-quota.d.mts +2 -0
- package/bin/commands/poll-quota.mjs +4 -0
- package/bin/commands/poll-summary.d.mts +1 -0
- package/bin/commands/poll-summary.mjs +30 -18
- package/bin/commands/poll-tick.d.mts +17 -0
- package/bin/commands/poll-tick.mjs +24 -0
- package/bin/commands/poll.d.mts +3 -9
- package/bin/commands/poll.mjs +64 -60
- package/bin/commands/stall-deadline.d.mts +20 -0
- package/bin/commands/stall-deadline.mjs +42 -0
- package/bin/commands/tick.mjs +1 -16
- package/bin/config/schema.d.mts +14 -0
- package/bin/config/schema.mjs +6 -0
- package/bin/events/config.d.mts +7 -0
- package/bin/events/config.mjs +66 -0
- package/bin/events/envelope.d.mts +4 -0
- package/bin/events/envelope.mjs +27 -0
- package/bin/events/filters.d.mts +8 -0
- package/bin/events/filters.mjs +27 -0
- package/bin/events/health.d.mts +14 -0
- package/bin/events/health.mjs +27 -0
- package/bin/events/matcher.d.mts +2 -0
- package/bin/events/matcher.mjs +32 -0
- package/bin/events/relay.d.mts +11 -0
- package/bin/events/relay.mjs +86 -0
- package/bin/events/serve.d.mts +10 -0
- package/bin/events/serve.mjs +137 -0
- package/bin/events/sse.d.mts +10 -0
- package/bin/events/sse.mjs +50 -0
- package/bin/events/types.d.mts +69 -0
- package/bin/events/types.mjs +1 -0
- package/bin/events/waiter.d.mts +47 -0
- package/bin/events/waiter.mjs +80 -0
- package/bin/github/batch-first-page.d.mts +17 -0
- package/bin/github/batch-first-page.mjs +48 -0
- package/bin/github/batch-page.d.mts +2 -0
- package/bin/github/batch-page.mjs +2 -2
- package/bin/github/batch-stack-evidence.d.mts +3 -1
- package/bin/github/batch-stack-evidence.mjs +4 -2
- package/bin/github/batch-viewer.d.mts +24 -0
- package/bin/github/batch-viewer.mjs +66 -0
- package/bin/github/batch.d.mts +1 -1
- package/bin/github/batch.mjs +30 -35
- package/bin/github/check-annotations-batch.mjs +1 -7
- package/bin/github/gql/batch-pr-viewer.gql +46 -0
- package/bin/github/gql-strip-viewer.d.mts +7 -0
- package/bin/github/gql-strip-viewer.mjs +14 -0
- package/bin/github/queries.d.mts +8 -0
- package/bin/github/queries.mjs +9 -0
- package/bin/github/thread-comments.d.mts +1 -1
- package/bin/github/thread-comments.mjs +7 -7
- package/bin/types/iterate.d.mts +9 -0
- package/bin/util/chunks.d.mts +2 -0
- package/bin/util/chunks.mjs +8 -0
- package/package.json +1 -1
- package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex.mcp.json +1 -1
- package/plugins/pr-shepherd/.mcp.json +1 -1
- package/plugins/pr-shepherd/package-lock.json +4 -4
- package/plugins/pr-shepherd/package.json +1 -1
- package/pr-shepherd.schema.json +21 -0
package/bin/github/queries.mjs
CHANGED
|
@@ -8,12 +8,19 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { readFileSync } from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
|
+
import { stripViewerFields } from "./gql-strip-viewer.mjs";
|
|
11
12
|
const gql = (name) => readFileSync(join(import.meta.dirname, "gql", name), "utf8");
|
|
12
13
|
const withSharedFragments = (query) => `${gql("ref-rules.gql")}\n${gql("pr-merge-policy.gql")}\n${gql("commit-check-suites.gql")}\n${query}`;
|
|
13
14
|
/** The primary batch query that fetches CI + comments + merge status in one round-trip. */
|
|
14
15
|
export const BATCH_PR_QUERY = withSharedFragments(gql("batch-pr.gql"));
|
|
16
|
+
/** `BatchPr` without any viewer field: a GitHub App may answer it. Paired with `BATCH_PR_VIEWER_QUERY`. */
|
|
17
|
+
export const BATCH_PR_DATA_QUERY = stripViewerFields(BATCH_PR_QUERY, "BatchPrData");
|
|
18
|
+
/** Viewer-relative fields (user token) for the node ids a viewer-free `BatchPr` read returned. */
|
|
19
|
+
export const BATCH_PR_VIEWER_QUERY = gql("batch-pr-viewer.gql");
|
|
15
20
|
/** Slim @include follow-up for outstanding batch-query connections. */
|
|
16
21
|
export const BATCH_PR_PAGE_QUERY = gql("batch-pr-page.gql");
|
|
22
|
+
/** `BatchPrPage` without viewer fields, for the viewer-free split read. */
|
|
23
|
+
export const BATCH_PR_PAGE_DATA_QUERY = stripViewerFields(BATCH_PR_PAGE_QUERY, "BatchPrPageData");
|
|
17
24
|
const POLL_SUMMARY_CHECK_CONTEXTS_FRAGMENT = gql("poll-summary-check-contexts.gql");
|
|
18
25
|
/** Compact per-PR fields shared by explicit-list and native-stack summary queries. */
|
|
19
26
|
export const POLL_SUMMARY_FRAGMENT = `${gql("ref-rules.gql")}\n${POLL_SUMMARY_CHECK_CONTEXTS_FRAGMENT}\n${gql("poll-summary-fragment.gql")}`;
|
|
@@ -52,6 +59,8 @@ export const MERGED_BASE_PULL_REQUESTS_QUERY = gql("merged-base-pull-requests.gq
|
|
|
52
59
|
export const SUGGESTION_THREADS_QUERY = gql("suggestion-threads.gql");
|
|
53
60
|
/** Fetches additional comments for a single review thread when its nested connection paginates. */
|
|
54
61
|
export const REVIEW_THREAD_COMMENTS_QUERY = gql("review-thread-comments.gql");
|
|
62
|
+
/** `ReviewThreadComments` without `viewerDidAuthor`, for the viewer-free split read. */
|
|
63
|
+
export const REVIEW_THREAD_COMMENTS_DATA_QUERY = stripViewerFields(REVIEW_THREAD_COMMENTS_QUERY, "ReviewThreadCommentsData");
|
|
55
64
|
/** Requested review-thread transcripts for best-effort reply seen markers. */
|
|
56
65
|
export const REPLY_THREAD_TRANSCRIPTS_QUERY = gql("reply-thread-transcripts.gql");
|
|
57
66
|
export const REPLY_THREAD_COMMENTS_QUERY = gql("reply-thread-comments.gql");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RateLimitInfo } from "./client.mts";
|
|
2
2
|
import type { RawThread } from "./batch-raw-types.mts";
|
|
3
|
-
export declare function hydrateThreadCommentPages(threads: RawThread[], initialRateLimit?: RateLimitInfo): Promise<{
|
|
3
|
+
export declare function hydrateThreadCommentPages(threads: RawThread[], initialRateLimit?: RateLimitInfo, viewerFree?: boolean): Promise<{
|
|
4
4
|
threads: RawThread[];
|
|
5
5
|
rateLimit?: RateLimitInfo;
|
|
6
6
|
}>;
|
|
@@ -3,10 +3,10 @@ import { readRestRawThread } from "./rest-thread-read.mjs";
|
|
|
3
3
|
import { graphqlWithRateLimit } from "./client.mjs";
|
|
4
4
|
import { GitHubRequestError } from "./errors.mjs";
|
|
5
5
|
import { paginateForward } from "./pagination.mjs";
|
|
6
|
-
import { REVIEW_THREAD_COMMENTS_QUERY } from "./queries.mjs";
|
|
6
|
+
import { REVIEW_THREAD_COMMENTS_DATA_QUERY, REVIEW_THREAD_COMMENTS_QUERY } from "./queries.mjs";
|
|
7
7
|
import { mapPool } from "../util/pool.mjs";
|
|
8
8
|
const THREAD_COMMENT_PAGE_CONCURRENCY = 4;
|
|
9
|
-
async function hydrateGraphqlThreadCommentPages(threads, initialRateLimit) {
|
|
9
|
+
async function hydrateGraphqlThreadCommentPages(threads, initialRateLimit, viewerFree = false) {
|
|
10
10
|
const gate = {
|
|
11
11
|
rateLimit: initialRateLimit,
|
|
12
12
|
exhausted: initialRateLimit?.remaining === 0,
|
|
@@ -15,7 +15,7 @@ async function hydrateGraphqlThreadCommentPages(threads, initialRateLimit) {
|
|
|
15
15
|
if (gate.error !== undefined)
|
|
16
16
|
return thread;
|
|
17
17
|
try {
|
|
18
|
-
return await hydrateThreadCommentPage(thread, gate);
|
|
18
|
+
return await hydrateThreadCommentPage(thread, gate, viewerFree);
|
|
19
19
|
}
|
|
20
20
|
catch (error) {
|
|
21
21
|
gate.error ??= error;
|
|
@@ -26,7 +26,7 @@ async function hydrateGraphqlThreadCommentPages(threads, initialRateLimit) {
|
|
|
26
26
|
throw gate.error;
|
|
27
27
|
return { threads: hydrated, rateLimit: gate.rateLimit };
|
|
28
28
|
}
|
|
29
|
-
async function hydrateThreadCommentPage(thread, gate) {
|
|
29
|
+
async function hydrateThreadCommentPage(thread, gate, viewerFree) {
|
|
30
30
|
const pageInfo = thread.comments.pageInfo;
|
|
31
31
|
if (!pageInfo?.hasNextPage || !pageInfo.endCursor)
|
|
32
32
|
return thread;
|
|
@@ -36,7 +36,7 @@ async function hydrateThreadCommentPage(thread, gate) {
|
|
|
36
36
|
if (gate.exhausted) {
|
|
37
37
|
throw new GitHubRequestError("GitHub GraphQL rate limit remaining is 0; thread comment pagination incomplete", { status: 403, rateLimit: gate.rateLimit });
|
|
38
38
|
}
|
|
39
|
-
const res = await graphqlWithRateLimit(REVIEW_THREAD_COMMENTS_QUERY, {
|
|
39
|
+
const res = await graphqlWithRateLimit(viewerFree ? REVIEW_THREAD_COMMENTS_DATA_QUERY : REVIEW_THREAD_COMMENTS_QUERY, {
|
|
40
40
|
threadId: thread.id,
|
|
41
41
|
...(cursor ? { commentsCursor: cursor } : {}),
|
|
42
42
|
});
|
|
@@ -62,8 +62,8 @@ async function hydrateThreadCommentPage(thread, gate) {
|
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
export function hydrateThreadCommentPages(threads, initialRateLimit) {
|
|
66
|
-
return githubOperation("ReviewThreadComments", () => hydrateGraphqlThreadCommentPages(threads, initialRateLimit), async () => ({
|
|
65
|
+
export function hydrateThreadCommentPages(threads, initialRateLimit, viewerFree = false) {
|
|
66
|
+
return githubOperation("ReviewThreadComments", () => hydrateGraphqlThreadCommentPages(threads, initialRateLimit, viewerFree), async () => ({
|
|
67
67
|
threads: await mapPool(threads, THREAD_COMMENT_PAGE_CONCURRENCY, async (thread) => thread.comments.pageInfo?.hasNextPage ? readRestRawThread(thread.id) : thread),
|
|
68
68
|
rateLimit: initialRateLimit,
|
|
69
69
|
}));
|
package/bin/types/iterate.d.mts
CHANGED
|
@@ -200,6 +200,15 @@ export interface IterateCommandOptions extends GlobalOptions {
|
|
|
200
200
|
stallDeadlineSink?: {
|
|
201
201
|
ciStartDeadlineSeconds?: number;
|
|
202
202
|
};
|
|
203
|
+
/**
|
|
204
|
+
* Internal. Poll receives the PR's head SHA and head branch from the tick's batch data so
|
|
205
|
+
* event-driven waits can match webhook events. Never serialized into a result. Excluded from
|
|
206
|
+
* the public `IterateInput` in api.mts.
|
|
207
|
+
*/
|
|
208
|
+
eventTargetSink?: {
|
|
209
|
+
headSha?: string;
|
|
210
|
+
headRef?: string;
|
|
211
|
+
};
|
|
203
212
|
/** Shepherd through readiness and emit the exact merge/queue command when ready. */
|
|
204
213
|
merge?: boolean;
|
|
205
214
|
/** Override `iterate.instructions` for this call. */
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "pr-shepherd-plugin",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"pr-shepherd": "1.
|
|
10
|
+
"pr-shepherd": "1.5.0"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"node_modules/@hono/node-server": {
|
|
@@ -889,9 +889,9 @@
|
|
|
889
889
|
}
|
|
890
890
|
},
|
|
891
891
|
"node_modules/pr-shepherd": {
|
|
892
|
-
"version": "1.
|
|
893
|
-
"resolved": "https://registry.npmjs.org/pr-shepherd/-/pr-shepherd-1.
|
|
894
|
-
"integrity": "sha512-
|
|
892
|
+
"version": "1.5.0",
|
|
893
|
+
"resolved": "https://registry.npmjs.org/pr-shepherd/-/pr-shepherd-1.5.0.tgz",
|
|
894
|
+
"integrity": "sha512-flRD8kbqdaRH9STn+DO4LBRj6WMOUUYYdMd7nkXW0dut08CJnkLildPmJ8U0GZqJ9LPOW5wCwpVJu2xSGWnXig==",
|
|
895
895
|
"license": "MIT",
|
|
896
896
|
"dependencies": {
|
|
897
897
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
package/pr-shepherd.schema.json
CHANGED
|
@@ -242,6 +242,27 @@
|
|
|
242
242
|
},
|
|
243
243
|
"additionalProperties": false
|
|
244
244
|
},
|
|
245
|
+
"events": {
|
|
246
|
+
"default": {},
|
|
247
|
+
"type": "object",
|
|
248
|
+
"properties": {
|
|
249
|
+
"source": {
|
|
250
|
+
"default": "none",
|
|
251
|
+
"type": "string",
|
|
252
|
+
"enum": [
|
|
253
|
+
"none",
|
|
254
|
+
"hook-harness"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
"fallback-interval-seconds": {
|
|
258
|
+
"default": 300,
|
|
259
|
+
"type": "number",
|
|
260
|
+
"exclusiveMinimum": 0,
|
|
261
|
+
"maximum": 86400
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"additionalProperties": false
|
|
265
|
+
},
|
|
245
266
|
"apply": {
|
|
246
267
|
"default": {},
|
|
247
268
|
"type": "object",
|