paperclip-github-plugin 0.17.5 → 0.17.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/README.md CHANGED
@@ -85,7 +85,7 @@ A pull-request link may include `followThroughAssigneeAgentId`, an optional Pape
85
85
 
86
86
  The worker validates an explicit owner against the authoritative Paperclip agent service before writing the link. The agent must exist and belong to the authenticated company; missing and cross-company ids fail closed. Successful owner changes carry `followThroughAssigneeUpdatedAt` in the durable link and agent-tool changes remain visible in the existing issue interaction ledger.
87
87
 
88
- The owner is stored on the PR-link entity, so unrelated title/state refreshes, process restarts, and execution-state cleanup do not remove it. Old link records without the property remain valid and use the previous fallback behavior. For actionable direct-PR work, assignment precedence is: an active execution-state `returnAssignee`, the PR's durable follow-through owner, the configured company executor, then the configured default assignee. Red CI, unresolved review threads, trusted follow-up, and merge-conflict/action-required states assign and wake the selected owner. A healthy external-maintainer wait remains `in_review` and unassigned. Effective-state fingerprints include durable routing so unchanged polls neither repeat the mutation nor enqueue another wake.
88
+ The owner is stored on the PR-link entity, so unrelated title/state refreshes, process restarts, and execution-state cleanup do not remove it. Old link records without the property remain valid and use the previous fallback behavior. For actionable direct-PR work, assignment precedence is: an active execution-state `returnAssignee`, the PR's durable follow-through owner, the configured company executor, then the configured default assignee. Red CI, unresolved review threads, trusted follow-up, and merge-conflict/action-required states assign and wake the selected owner. A healthy external-maintainer wait remains `in_review` with no agent assignee; a human assignee is left in place, because a person parked on such an issue is the reviewer the work is waiting on. Effective-state fingerprints include durable routing so unchanged polls neither repeat the mutation nor enqueue another wake.
89
89
 
90
90
  ### Project pull request command center
91
91
 
@@ -203,7 +203,7 @@ Additional behavior:
203
203
  - Newly imported issues that finish sync in `todo` and are assigned to an agent enqueue an assignee wakeup so the agent can pick them up promptly.
204
204
  - For linked pull requests, GitHub Sync treats merge-conflict, behind-branch, blocked, draft, unstable merge states, and unresolved review threads as executor work, while merge-ready states such as `CLEAN` and `HAS_HOOKS` can move work into `in_review` when CI is green and review threads are resolved. If an issue is already `blocked` and GitHub reports only pending external merge requirements while CI is unfinished, sync preserves the external wait instead of waking an executor. A stale aggregate `CHANGES_REQUESTED` review decision alone does not move that maintainer wait back to active execution. Transient `UNKNOWN` mergeability also does not move an already `in_review` maintainer wait back to active execution when CI is green and review threads are resolved.
205
205
  - Imported issues that are already `blocked` stay `blocked` while any first-class `blockedBy` issue is still non-terminal, even if the linked GitHub pull request is otherwise green and review-ready.
206
- - When sync moves work into `in_review`, GitHub Sync first follows the Paperclip issue execution policy's current reviewer or approver when that stage is visible on the issue. If Paperclip exposes an internal review or approval stage but not yet the participant, the plugin falls back to the configured reviewer or approver handoff assignee. If the transition is only a healthy linked-PR wait with no visible internal review or approval stage, GitHub Sync leaves the issue unassigned so it can wait on normal maintainer review without waking an internal owner. An execution state explicitly marked `completed` contains historical stage and decision fields, not active routing: GitHub Sync clears that completed policy/state and the stale internal assignee atomically when restoring `done` to `in_review`, and it emits no assignment wakeup.
206
+ - When sync moves work into `in_review`, GitHub Sync first follows the Paperclip issue execution policy's current reviewer or approver when that stage is visible on the issue. If Paperclip exposes an internal review or approval stage but not yet the participant, the plugin falls back to the configured reviewer or approver handoff assignee. If the transition is only a healthy linked-PR wait with no visible internal review or approval stage, GitHub Sync leaves the issue unassigned so it can wait on normal maintainer review without waking an internal owner. An execution state explicitly marked `completed` contains historical stage and decision fields, not active routing: GitHub Sync clears that completed policy/state and the stale internal agent assignee atomically when restoring `done` to `in_review`, keeps any human assignee, and emits no assignment wakeup.
207
207
  - When sync moves work back into active execution, GitHub Sync first follows the Paperclip issue execution policy `returnAssignee` when it is available. Otherwise it uses the durable pull-request follow-through owner, then falls back to the configured executor handoff assignee and finally to the default imported assignee.
208
208
  - Sync-driven handoffs to agent assignees best-effort enqueue an explicit wakeup so the next reviewer, approver, or executor can pick the issue up even when their agent is not running heartbeats.
209
209
  - After applying a GitHub-derived state, GitHub Sync immediately stores a bounded fingerprint of the effective issue/PR condition (including head SHA, closure outcome, and the highest-priority actionable check/review/merge condition). While local Paperclip status, assignment, and execution metadata still match the desired state, the same fingerprint remains quiescent: sync does not repeat the transition, comment, or wake, including for `done`/`cancelled` closure outcomes and directly PR-linked issues. If local state later drifts under unchanged remote evidence, sync reconciles it through a drift-specific journal attempt and issues one required wake when the corrected state is actionable and agent-owned. Raw `UNKNOWN`/aggregate jitter that does not change the effective action cannot re-arm the transition. A changed effective fingerprint or a trusted new issue/PR/review comment bypasses suppression; untrusted comment-count changes do not. Status/comment watermarks advance only after their action succeeds. When a required assignee wake fails, the successful mutation and a bounded pending-wake record are already durable, so the next sync retries only the wake without repeating the status change or comment.
@@ -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 decide reviewer routing.
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.5"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
722
+ var MANIFEST_VERSION = "0.17.7"?.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),
@@ -6429,6 +6430,10 @@ function normalizePaperclipIssueExecutionState(value) {
6429
6430
  ...lastDecisionOutcome !== null ? { lastDecisionOutcome } : {}
6430
6431
  };
6431
6432
  }
6433
+ function readPaperclipIssueAssigneeUserId(issue) {
6434
+ if (!issue) return null;
6435
+ return normalizeOptionalString2(issue.assigneeUserId) ?? null;
6436
+ }
6432
6437
  function getPaperclipIssueAssigneePrincipal(issue) {
6433
6438
  const record = issue;
6434
6439
  const assigneeAgentId = normalizeOptionalString2(record.assigneeAgentId);
@@ -10147,6 +10152,21 @@ function isPaperclipIssuePatchApplied(params) {
10147
10152
  )) return false;
10148
10153
  return true;
10149
10154
  }
10155
+ function findSettledNoopAttempt(events, attemptPrefix) {
10156
+ const resultSuffix = ":result:noop";
10157
+ const settled = events.filter((candidate) => {
10158
+ if (!candidate.dedupeKey.startsWith(attemptPrefix)) return false;
10159
+ return /^[^:]+:result:noop$/.test(candidate.dedupeKey.slice(attemptPrefix.length));
10160
+ }).sort(
10161
+ (left, right) => right.occurredAt.localeCompare(left.occurredAt) || right.dedupeKey.localeCompare(left.dedupeKey)
10162
+ );
10163
+ for (const event of settled) {
10164
+ const dedupeBase = event.dedupeKey.slice(0, -resultSuffix.length);
10165
+ const intent = events.find((candidate) => candidate.dedupeKey === `${dedupeBase}:intent`);
10166
+ if (intent) return { dedupeBase, occurredAt: intent.occurredAt };
10167
+ }
10168
+ return void 0;
10169
+ }
10150
10170
  async function updatePaperclipIssueState(ctx, params) {
10151
10171
  const {
10152
10172
  companyId,
@@ -10174,6 +10194,9 @@ async function updatePaperclipIssueState(ctx, params) {
10174
10194
  syncContext,
10175
10195
  nextAssignee
10176
10196
  });
10197
+ const liveIssue = await ctx.issues.get(issueId, companyId);
10198
+ const liveCurrentStatus = liveIssue?.status ?? currentStatus;
10199
+ const liveSyncContext = liveIssue ? getPaperclipIssueSyncContext(liveIssue) : syncContext;
10177
10200
  const issuePatch = {
10178
10201
  status: nextStatus,
10179
10202
  ...syncExecutionStatePatch !== void 0 ? { executionState: syncExecutionStatePatch } : {},
@@ -10189,7 +10212,7 @@ async function updatePaperclipIssueState(ctx, params) {
10189
10212
  }
10190
10213
  } else if (clearAssignee) {
10191
10214
  issuePatch.assigneeAgentId = null;
10192
- issuePatch.assigneeUserId = null;
10215
+ issuePatch.assigneeUserId = readPaperclipIssueAssigneeUserId(liveIssue) ?? (syncContext.assignee?.kind === "user" ? syncContext.assignee.id : null);
10193
10216
  }
10194
10217
  if (statusWillChange && !trimmedTransitionComment) {
10195
10218
  throw new Error("GitHub Sync refused to update a Paperclip issue status without an explanatory transition comment.");
@@ -10197,9 +10220,6 @@ async function updatePaperclipIssueState(ctx, params) {
10197
10220
  if (statusWillChange && typeof ctx.issues.createComment !== "function") {
10198
10221
  throw new Error("This Paperclip runtime does not expose issue comment creation, so GitHub Sync refused to update a Paperclip issue status without an explanatory comment.");
10199
10222
  }
10200
- const liveIssue = await ctx.issues.get(issueId, companyId);
10201
- const liveCurrentStatus = liveIssue?.status ?? currentStatus;
10202
- const liveSyncContext = liveIssue ? getPaperclipIssueSyncContext(liveIssue) : syncContext;
10203
10223
  const issuePatchAlreadyApplied = isPaperclipIssuePatchApplied({
10204
10224
  currentStatus: liveCurrentStatus,
10205
10225
  syncContext: liveSyncContext,
@@ -10271,8 +10291,15 @@ async function updatePaperclipIssueState(ctx, params) {
10271
10291
  reconciliationAttemptId = interactionDedupeBase.slice(attemptPrefix.length);
10272
10292
  interactionOccurredAt = latestOpenAttemptIntent.occurredAt;
10273
10293
  } else {
10274
- reconciliationAttemptId = randomUUID();
10275
- interactionDedupeBase = `${attemptPrefix}${reconciliationAttemptId}`;
10294
+ const settledNoopAttempt = !statusWillChange && issuePatchAlreadyApplied ? findSettledNoopAttempt(existingInteractionEvents, attemptPrefix) : void 0;
10295
+ if (settledNoopAttempt) {
10296
+ interactionDedupeBase = settledNoopAttempt.dedupeBase;
10297
+ reconciliationAttemptId = interactionDedupeBase.slice(attemptPrefix.length);
10298
+ interactionOccurredAt = settledNoopAttempt.occurredAt;
10299
+ } else {
10300
+ reconciliationAttemptId = randomUUID();
10301
+ interactionDedupeBase = `${attemptPrefix}${reconciliationAttemptId}`;
10302
+ }
10276
10303
  }
10277
10304
  }
10278
10305
  const mutationPatchBase = `${mutationFamilyBase}${reconciliationAttemptId ? `:attempt:${reconciliationAttemptId}` : ""}:patch:${createHash("sha256").update(JSON.stringify(issuePatch)).digest("hex").slice(0, 32)}:applied:${mutationExpectedStateFingerprint}`;
@@ -13179,6 +13206,37 @@ function appendOptionalAiAuthorshipFooter(body, subject, llmModel) {
13179
13206
  }
13180
13207
  return `${trimmedBody}${formatAiAuthorshipFooter(subject, llmModel)}`;
13181
13208
  }
13209
+ var REVIEWER_CANDIDATE_ASSOCIATIONS = /* @__PURE__ */ new Set(["owner", "member", "collaborator"]);
13210
+ function buildGitHubIssueParticipants(issue, comments) {
13211
+ const participants = [];
13212
+ const seen = /* @__PURE__ */ new Set();
13213
+ if (issue.authorLogin) {
13214
+ participants.push({
13215
+ login: issue.authorLogin,
13216
+ role: "author",
13217
+ ...issue.authorAssociation ? { association: issue.authorAssociation } : {},
13218
+ isBot: issue.authorIsBot === true,
13219
+ ...issue.authorUrl ? { url: issue.authorUrl } : {}
13220
+ });
13221
+ seen.add(issue.authorLogin.toLowerCase());
13222
+ }
13223
+ for (const comment of comments) {
13224
+ const login = comment.authorLogin;
13225
+ if (!login || seen.has(login.toLowerCase())) {
13226
+ continue;
13227
+ }
13228
+ seen.add(login.toLowerCase());
13229
+ participants.push({
13230
+ login,
13231
+ role: "commenter",
13232
+ ...comment.authorAssociation ? { association: comment.authorAssociation } : {},
13233
+ isBot: comment.authorIsBot === true,
13234
+ ...comment.authorUrl ? { url: comment.authorUrl } : {}
13235
+ });
13236
+ }
13237
+ const reviewerCandidates = participants.filter((participant) => !participant.isBot && participant.association !== void 0 && REVIEWER_CANDIDATE_ASSOCIATIONS.has(participant.association)).map((participant) => participant.login);
13238
+ return { participants, reviewerCandidates };
13239
+ }
13182
13240
  async function listAllGitHubIssueComments(octokit, repository, issueNumber) {
13183
13241
  const comments = [];
13184
13242
  for await (const response of octokit.paginate.iterator(octokit.rest.issues.listComments, {
@@ -13197,6 +13255,7 @@ async function listAllGitHubIssueComments(octokit, repository, issueNumber) {
13197
13255
  url: comment.html_url ?? void 0,
13198
13256
  authorLogin: normalizeGitHubUserLogin(comment.user?.login),
13199
13257
  ...normalizeGitHubLowercaseString(comment.author_association) ? { authorAssociation: normalizeGitHubLowercaseString(comment.author_association) } : {},
13258
+ ...comment.user?.type === "Bot" ? { authorIsBot: true } : {},
13200
13259
  authorUrl: comment.user?.html_url ?? void 0,
13201
13260
  authorAvatarUrl: comment.user?.avatar_url ?? void 0,
13202
13261
  createdAt: comment.created_at ?? void 0,
@@ -17135,6 +17194,14 @@ function registerGitHubAgentTools(ctx) {
17135
17194
  });
17136
17195
  const issue = normalizeGitHubIssueRecord(response.data);
17137
17196
  const linkedPullRequests = await listLinkedPullRequestsForIssue(octokit, target.repository, target.issueNumber);
17197
+ let issueComments = [];
17198
+ let participantsWarning;
17199
+ try {
17200
+ issueComments = await listAllGitHubIssueComments(octokit, target.repository, target.issueNumber);
17201
+ } catch (error) {
17202
+ participantsWarning = `Issue comments could not be listed, so participants only include the author: ${getErrorMessage(error)}`;
17203
+ }
17204
+ const { participants, reviewerCandidates } = buildGitHubIssueParticipants(issue, issueComments);
17138
17205
  const assignees = (response.data.assignees ?? []).map((assignee) => assignee?.login ?? "").filter(Boolean);
17139
17206
  const milestone = response.data.milestone ? {
17140
17207
  number: response.data.milestone.number,
@@ -17158,8 +17225,12 @@ function registerGitHubAgentTools(ctx) {
17158
17225
  author: issue.authorLogin ? {
17159
17226
  login: issue.authorLogin,
17160
17227
  ...issue.authorUrl ? { url: issue.authorUrl } : {},
17161
- ...issue.authorAssociation ? { association: issue.authorAssociation } : {}
17228
+ ...issue.authorAssociation ? { association: issue.authorAssociation } : {},
17229
+ isBot: issue.authorIsBot === true
17162
17230
  } : null,
17231
+ participants,
17232
+ reviewerCandidates,
17233
+ ...participantsWarning ? { participantsWarning } : {},
17163
17234
  labels: issue.labels,
17164
17235
  assignees,
17165
17236
  milestone,
@@ -18232,6 +18303,7 @@ var __testing = {
18232
18303
  hasUnresolvedPaperclipIssueBlocker,
18233
18304
  isHealthyMaintainerWaitTransition,
18234
18305
  isPaperclipIssuePatchApplied,
18306
+ findSettledNoopAttempt,
18235
18307
  listTrustedNewLinkedPullRequestCommentSources,
18236
18308
  normalizePaperclipIssueAssigneePrincipal,
18237
18309
  normalizeImportRegistry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.17.5",
3
+ "version": "0.17.7",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",