paperclip-github-plugin 0.17.5 → 0.17.6
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 +1 -1
- package/dist/manifest.js +2 -2
- package/dist/worker.js +72 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -278,7 +278,7 @@ The plugin exposes GitHub workflow tools to Paperclip agents, including:
|
|
|
278
278
|
|
|
279
279
|
Branch publication uses an isolated temporary bare repository backed by the selected trusted-workspace checkout's object database. It does not execute repository hooks, accept arbitrary refspecs, or honor repository-local remotes. An optional checkout path must resolve inside the issue execution workspace, while the selected target repository must be a canonical GitHub `owner/repo` reference. Publication rejects owner-qualified heads, base-branch targets, non-fast-forward updates, cross-project issues, mismatched local branch tips, and remote SHA mismatches.
|
|
280
280
|
|
|
281
|
-
Optional `labels`, `userReviewers`, and `teamReviewers` are applied right after the pull request exists (for example the approved `type:` label and the linked issue author as reviewer). Those follow-up calls never undo the pull request: their outcome is reported in the result as `labels`, `requestedReviewers`, `requestedTeams`, or `warnings`. The tool also appends the new pull request to the issue's GitHub link record immediately, so the Paperclip issue card shows the linked pull request without waiting for the next sync. `update_pull_request` accepts a replacement `labels` set, and `get_issue` returns the issue `author` so agents can
|
|
281
|
+
Optional `labels`, `userReviewers`, and `teamReviewers` are applied right after the pull request exists (for example the approved `type:` label and the linked issue author as reviewer). Those follow-up calls never undo the pull request: their outcome is reported in the result as `labels`, `requestedReviewers`, `requestedTeams`, or `warnings`. The tool also appends the new pull request to the issue's GitHub link record immediately, so the Paperclip issue card shows the linked pull request without waiting for the next sync. `update_pull_request` accepts a replacement `labels` set, and `get_issue` returns the issue `author`, all `participants` (author and distinct commenters with their repository association), and `reviewerCandidates` (non-bot owners, members, and collaborators among them) so agents can request the reporter and the maintainers who joined the discussion as reviewers.
|
|
282
282
|
|
|
283
283
|
The call is ordered and retry-safe rather than a cross-system transaction: a published branch may remain if GitHub PR creation or Paperclip link persistence fails. On retry, the tool re-verifies and republishes the exact SHA, then recovers an already-open PR only when repository, head, base, and head SHA all match before repairing the link and metric. It never deletes a branch or closes a PR as automatic compensation.
|
|
284
284
|
|
package/dist/manifest.js
CHANGED
|
@@ -123,7 +123,7 @@ var GITHUB_AGENT_TOOLS = [
|
|
|
123
123
|
{
|
|
124
124
|
name: "get_issue",
|
|
125
125
|
displayName: "Get Issue",
|
|
126
|
-
description: "Read one GitHub issue with its metadata, author, assignees, labels, milestone, and linked pull requests.",
|
|
126
|
+
description: "Read one GitHub issue with its metadata, author, participants (author plus distinct commenters with their repository association), reviewerCandidates (non-bot owners, members, and collaborators among them, for pull request reviewer routing), assignees, labels, milestone, and linked pull requests.",
|
|
127
127
|
parametersSchema: {
|
|
128
128
|
type: "object",
|
|
129
129
|
additionalProperties: false,
|
|
@@ -719,7 +719,7 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
|
|
|
719
719
|
var require2 = createRequire(import.meta.url);
|
|
720
720
|
var packageJson = require2("../package.json");
|
|
721
721
|
var SCHEDULE_TICK_CRON = "* * * * *";
|
|
722
|
-
var MANIFEST_VERSION = "0.17.
|
|
722
|
+
var MANIFEST_VERSION = "0.17.6"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
|
|
723
723
|
var COMPANY_SECRET_REF_VALUE_SCHEMA = {
|
|
724
724
|
anyOf: [
|
|
725
725
|
{ type: "string" },
|
package/dist/worker.js
CHANGED
|
@@ -134,7 +134,7 @@ var GITHUB_AGENT_TOOLS = [
|
|
|
134
134
|
{
|
|
135
135
|
name: "get_issue",
|
|
136
136
|
displayName: "Get Issue",
|
|
137
|
-
description: "Read one GitHub issue with its metadata, author, assignees, labels, milestone, and linked pull requests.",
|
|
137
|
+
description: "Read one GitHub issue with its metadata, author, participants (author plus distinct commenters with their repository association), reviewerCandidates (non-bot owners, members, and collaborators among them, for pull request reviewer routing), assignees, labels, milestone, and linked pull requests.",
|
|
138
138
|
parametersSchema: {
|
|
139
139
|
type: "object",
|
|
140
140
|
additionalProperties: false,
|
|
@@ -5806,6 +5806,7 @@ function normalizeGitHubIssueRecord(issue) {
|
|
|
5806
5806
|
...authorUrl ? { authorUrl } : {},
|
|
5807
5807
|
...authorAvatarUrl ? { authorAvatarUrl } : {},
|
|
5808
5808
|
...normalizeGitHubLowercaseString(issue.author_association) ? { authorAssociation: normalizeGitHubLowercaseString(issue.author_association) } : {},
|
|
5809
|
+
...issue.user?.type === "Bot" ? { authorIsBot: true } : {},
|
|
5809
5810
|
labels: normalizeGitHubIssueLabels(issue.labels),
|
|
5810
5811
|
state: issue.state === "closed" ? "closed" : "open",
|
|
5811
5812
|
stateReason: normalizeGitHubIssueStateReason(issue.state_reason),
|
|
@@ -10147,6 +10148,21 @@ function isPaperclipIssuePatchApplied(params) {
|
|
|
10147
10148
|
)) return false;
|
|
10148
10149
|
return true;
|
|
10149
10150
|
}
|
|
10151
|
+
function findSettledNoopAttempt(events, attemptPrefix) {
|
|
10152
|
+
const resultSuffix = ":result:noop";
|
|
10153
|
+
const settled = events.filter((candidate) => {
|
|
10154
|
+
if (!candidate.dedupeKey.startsWith(attemptPrefix)) return false;
|
|
10155
|
+
return /^[^:]+:result:noop$/.test(candidate.dedupeKey.slice(attemptPrefix.length));
|
|
10156
|
+
}).sort(
|
|
10157
|
+
(left, right) => right.occurredAt.localeCompare(left.occurredAt) || right.dedupeKey.localeCompare(left.dedupeKey)
|
|
10158
|
+
);
|
|
10159
|
+
for (const event of settled) {
|
|
10160
|
+
const dedupeBase = event.dedupeKey.slice(0, -resultSuffix.length);
|
|
10161
|
+
const intent = events.find((candidate) => candidate.dedupeKey === `${dedupeBase}:intent`);
|
|
10162
|
+
if (intent) return { dedupeBase, occurredAt: intent.occurredAt };
|
|
10163
|
+
}
|
|
10164
|
+
return void 0;
|
|
10165
|
+
}
|
|
10150
10166
|
async function updatePaperclipIssueState(ctx, params) {
|
|
10151
10167
|
const {
|
|
10152
10168
|
companyId,
|
|
@@ -10271,8 +10287,15 @@ async function updatePaperclipIssueState(ctx, params) {
|
|
|
10271
10287
|
reconciliationAttemptId = interactionDedupeBase.slice(attemptPrefix.length);
|
|
10272
10288
|
interactionOccurredAt = latestOpenAttemptIntent.occurredAt;
|
|
10273
10289
|
} else {
|
|
10274
|
-
|
|
10275
|
-
|
|
10290
|
+
const settledNoopAttempt = !statusWillChange && issuePatchAlreadyApplied ? findSettledNoopAttempt(existingInteractionEvents, attemptPrefix) : void 0;
|
|
10291
|
+
if (settledNoopAttempt) {
|
|
10292
|
+
interactionDedupeBase = settledNoopAttempt.dedupeBase;
|
|
10293
|
+
reconciliationAttemptId = interactionDedupeBase.slice(attemptPrefix.length);
|
|
10294
|
+
interactionOccurredAt = settledNoopAttempt.occurredAt;
|
|
10295
|
+
} else {
|
|
10296
|
+
reconciliationAttemptId = randomUUID();
|
|
10297
|
+
interactionDedupeBase = `${attemptPrefix}${reconciliationAttemptId}`;
|
|
10298
|
+
}
|
|
10276
10299
|
}
|
|
10277
10300
|
}
|
|
10278
10301
|
const mutationPatchBase = `${mutationFamilyBase}${reconciliationAttemptId ? `:attempt:${reconciliationAttemptId}` : ""}:patch:${createHash("sha256").update(JSON.stringify(issuePatch)).digest("hex").slice(0, 32)}:applied:${mutationExpectedStateFingerprint}`;
|
|
@@ -13179,6 +13202,37 @@ function appendOptionalAiAuthorshipFooter(body, subject, llmModel) {
|
|
|
13179
13202
|
}
|
|
13180
13203
|
return `${trimmedBody}${formatAiAuthorshipFooter(subject, llmModel)}`;
|
|
13181
13204
|
}
|
|
13205
|
+
var REVIEWER_CANDIDATE_ASSOCIATIONS = /* @__PURE__ */ new Set(["owner", "member", "collaborator"]);
|
|
13206
|
+
function buildGitHubIssueParticipants(issue, comments) {
|
|
13207
|
+
const participants = [];
|
|
13208
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13209
|
+
if (issue.authorLogin) {
|
|
13210
|
+
participants.push({
|
|
13211
|
+
login: issue.authorLogin,
|
|
13212
|
+
role: "author",
|
|
13213
|
+
...issue.authorAssociation ? { association: issue.authorAssociation } : {},
|
|
13214
|
+
isBot: issue.authorIsBot === true,
|
|
13215
|
+
...issue.authorUrl ? { url: issue.authorUrl } : {}
|
|
13216
|
+
});
|
|
13217
|
+
seen.add(issue.authorLogin.toLowerCase());
|
|
13218
|
+
}
|
|
13219
|
+
for (const comment of comments) {
|
|
13220
|
+
const login = comment.authorLogin;
|
|
13221
|
+
if (!login || seen.has(login.toLowerCase())) {
|
|
13222
|
+
continue;
|
|
13223
|
+
}
|
|
13224
|
+
seen.add(login.toLowerCase());
|
|
13225
|
+
participants.push({
|
|
13226
|
+
login,
|
|
13227
|
+
role: "commenter",
|
|
13228
|
+
...comment.authorAssociation ? { association: comment.authorAssociation } : {},
|
|
13229
|
+
isBot: comment.authorIsBot === true,
|
|
13230
|
+
...comment.authorUrl ? { url: comment.authorUrl } : {}
|
|
13231
|
+
});
|
|
13232
|
+
}
|
|
13233
|
+
const reviewerCandidates = participants.filter((participant) => !participant.isBot && participant.association !== void 0 && REVIEWER_CANDIDATE_ASSOCIATIONS.has(participant.association)).map((participant) => participant.login);
|
|
13234
|
+
return { participants, reviewerCandidates };
|
|
13235
|
+
}
|
|
13182
13236
|
async function listAllGitHubIssueComments(octokit, repository, issueNumber) {
|
|
13183
13237
|
const comments = [];
|
|
13184
13238
|
for await (const response of octokit.paginate.iterator(octokit.rest.issues.listComments, {
|
|
@@ -13197,6 +13251,7 @@ async function listAllGitHubIssueComments(octokit, repository, issueNumber) {
|
|
|
13197
13251
|
url: comment.html_url ?? void 0,
|
|
13198
13252
|
authorLogin: normalizeGitHubUserLogin(comment.user?.login),
|
|
13199
13253
|
...normalizeGitHubLowercaseString(comment.author_association) ? { authorAssociation: normalizeGitHubLowercaseString(comment.author_association) } : {},
|
|
13254
|
+
...comment.user?.type === "Bot" ? { authorIsBot: true } : {},
|
|
13200
13255
|
authorUrl: comment.user?.html_url ?? void 0,
|
|
13201
13256
|
authorAvatarUrl: comment.user?.avatar_url ?? void 0,
|
|
13202
13257
|
createdAt: comment.created_at ?? void 0,
|
|
@@ -17135,6 +17190,14 @@ function registerGitHubAgentTools(ctx) {
|
|
|
17135
17190
|
});
|
|
17136
17191
|
const issue = normalizeGitHubIssueRecord(response.data);
|
|
17137
17192
|
const linkedPullRequests = await listLinkedPullRequestsForIssue(octokit, target.repository, target.issueNumber);
|
|
17193
|
+
let issueComments = [];
|
|
17194
|
+
let participantsWarning;
|
|
17195
|
+
try {
|
|
17196
|
+
issueComments = await listAllGitHubIssueComments(octokit, target.repository, target.issueNumber);
|
|
17197
|
+
} catch (error) {
|
|
17198
|
+
participantsWarning = `Issue comments could not be listed, so participants only include the author: ${getErrorMessage(error)}`;
|
|
17199
|
+
}
|
|
17200
|
+
const { participants, reviewerCandidates } = buildGitHubIssueParticipants(issue, issueComments);
|
|
17138
17201
|
const assignees = (response.data.assignees ?? []).map((assignee) => assignee?.login ?? "").filter(Boolean);
|
|
17139
17202
|
const milestone = response.data.milestone ? {
|
|
17140
17203
|
number: response.data.milestone.number,
|
|
@@ -17158,8 +17221,12 @@ function registerGitHubAgentTools(ctx) {
|
|
|
17158
17221
|
author: issue.authorLogin ? {
|
|
17159
17222
|
login: issue.authorLogin,
|
|
17160
17223
|
...issue.authorUrl ? { url: issue.authorUrl } : {},
|
|
17161
|
-
...issue.authorAssociation ? { association: issue.authorAssociation } : {}
|
|
17224
|
+
...issue.authorAssociation ? { association: issue.authorAssociation } : {},
|
|
17225
|
+
isBot: issue.authorIsBot === true
|
|
17162
17226
|
} : null,
|
|
17227
|
+
participants,
|
|
17228
|
+
reviewerCandidates,
|
|
17229
|
+
...participantsWarning ? { participantsWarning } : {},
|
|
17163
17230
|
labels: issue.labels,
|
|
17164
17231
|
assignees,
|
|
17165
17232
|
milestone,
|
|
@@ -18232,6 +18299,7 @@ var __testing = {
|
|
|
18232
18299
|
hasUnresolvedPaperclipIssueBlocker,
|
|
18233
18300
|
isHealthyMaintainerWaitTransition,
|
|
18234
18301
|
isPaperclipIssuePatchApplied,
|
|
18302
|
+
findSettledNoopAttempt,
|
|
18235
18303
|
listTrustedNewLinkedPullRequestCommentSources,
|
|
18236
18304
|
normalizePaperclipIssueAssigneePrincipal,
|
|
18237
18305
|
normalizeImportRegistry,
|