paperclip-github-plugin 0.14.1 → 0.15.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 CHANGED
@@ -239,9 +239,9 @@ The plugin exposes GitHub workflow tools to Paperclip agents, including:
239
239
  - review-thread reads, replies, resolve and unresolve actions, and `request_pull_request_reviewers` reviewer requests
240
240
  - organization-level GitHub Project search/listing and pull-request-to-project association
241
241
 
242
- `create_pull_request` is the single agent-facing delivery call for both branch publication and PR creation. The caller supplies the Paperclip issue id, a plain local branch name, the exact 40-character local branch-tip SHA, the base branch, and the PR metadata. The trusted plugin worker verifies checkout ownership, resolves the issue's execution worktree and GitHub secret, verifies the checked-out branch, worktree HEAD, local branch tip, and base ancestry, publishes only that exact commit with a non-forcing refspec, reads the remote branch SHA back, and only then creates and links the PR. The GitHub credential is never returned to or injected into the calling agent.
242
+ `create_pull_request` is the single agent-facing delivery call for both branch publication and PR creation. The caller supplies the Paperclip issue id, a plain local branch name, the exact 40-character local branch-tip SHA, the base branch, and the PR metadata. The optional `repository` may select any GitHub repository, including one that is not mapped in Paperclip, provided it matches the issue execution workspace; if omitted, the issue project must have exactly one mapped repository. The trusted plugin worker verifies checkout ownership, resolves the issue's execution worktree and GitHub secret, verifies the checked-out branch, worktree HEAD, local branch tip, and base ancestry, publishes only that exact commit with a non-forcing refspec, reads the remote branch SHA back, and only then asks GitHub to create and link the PR. GitHub token permissions determine whether publication and PR creation are allowed. The credential is never returned to or injected into the calling agent.
243
243
 
244
- Branch publication uses an isolated temporary bare repository backed by the trusted workspace object database. It does not execute repository hooks, accept arbitrary refspecs, or honor agent-supplied remote URLs. Publication rejects owner-qualified heads, base-branch targets, non-fast-forward updates, cross-project issues, mismatched local branch tips, and remote SHA mismatches.
244
+ Branch publication uses an isolated temporary bare repository backed by the trusted workspace object database. It does not execute repository hooks, accept arbitrary refspecs, or honor repository-local remotes. The selected target repository is accepted only when it is a canonical GitHub `owner/repo` reference matching the trusted execution workspace. Publication rejects owner-qualified heads, base-branch targets, non-fast-forward updates, cross-project issues, mismatched local branch tips, and remote SHA mismatches.
245
245
 
246
246
  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.
247
247
 
package/dist/manifest.js CHANGED
@@ -260,10 +260,13 @@ var GITHUB_AGENT_TOOLS = [
260
260
  additionalProperties: false,
261
261
  required: ["paperclipIssueId", "head", "headCommitSha", "base", "title"],
262
262
  properties: {
263
- repository: repositoryProperty,
263
+ repository: {
264
+ type: "string",
265
+ description: "Target GitHub repository as owner/repo or https://github.com/owner/repo. It may be outside Paperclip repository mappings, but it must match the issue execution workspace. Omit only when the issue project has exactly one mapped repository."
266
+ },
264
267
  paperclipIssueId: {
265
268
  type: "string",
266
- description: "Paperclip issue id used to resolve the trusted project workspace, mapped GitHub repository, and durable pull-request link."
269
+ description: "Paperclip issue id used to resolve the trusted execution workspace and durable pull-request link."
267
270
  },
268
271
  head: {
269
272
  type: "string",
@@ -641,7 +644,7 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
641
644
  var require2 = createRequire(import.meta.url);
642
645
  var packageJson = require2("../package.json");
643
646
  var SCHEDULE_TICK_CRON = "* * * * *";
644
- var MANIFEST_VERSION = "0.14.1"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
647
+ var MANIFEST_VERSION = "0.15.0"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
645
648
  var manifest = {
646
649
  id: GITHUB_SYNC_PLUGIN_ID,
647
650
  apiVersion: 1,
package/dist/worker.js CHANGED
@@ -270,10 +270,13 @@ var GITHUB_AGENT_TOOLS = [
270
270
  additionalProperties: false,
271
271
  required: ["paperclipIssueId", "head", "headCommitSha", "base", "title"],
272
272
  properties: {
273
- repository: repositoryProperty,
273
+ repository: {
274
+ type: "string",
275
+ description: "Target GitHub repository as owner/repo or https://github.com/owner/repo. It may be outside Paperclip repository mappings, but it must match the issue execution workspace. Omit only when the issue project has exactly one mapped repository."
276
+ },
274
277
  paperclipIssueId: {
275
278
  type: "string",
276
- description: "Paperclip issue id used to resolve the trusted project workspace, mapped GitHub repository, and durable pull-request link."
279
+ description: "Paperclip issue id used to resolve the trusted execution workspace and durable pull-request link."
277
280
  },
278
281
  head: {
279
282
  type: "string",
@@ -15445,15 +15448,15 @@ function registerGitHubAgentTools(ctx) {
15445
15448
  if (!paperclipIssueId || !head || !headCommitSha || !base || !title) {
15446
15449
  throw new Error("paperclipIssueId, head, headCommitSha, base, and title are required.");
15447
15450
  }
15448
- const issueLinkScope = await resolveIssueGitHubLinkMapping(ctx, {
15449
- companyId: runCtx.companyId,
15450
- issueId: paperclipIssueId,
15451
- ...explicitRepository ? { repositoryUrl: explicitRepository } : {}
15452
- });
15453
- if (issueLinkScope.projectId !== runCtx.projectId) {
15451
+ const issue = await ctx.issues.get(paperclipIssueId, runCtx.companyId);
15452
+ if (!issue) {
15453
+ throw new Error("Paperclip issue was not found.");
15454
+ }
15455
+ const issueProjectId = normalizeOptionalToolString(issue.projectId);
15456
+ if (!issueProjectId || issueProjectId !== runCtx.projectId) {
15454
15457
  throw new Error("The selected Paperclip issue does not belong to the current tool run project.");
15455
15458
  }
15456
- if (issueLinkScope.issue.assigneeAgentId && issueLinkScope.issue.assigneeAgentId !== runCtx.agentId) {
15459
+ if (issue.assigneeAgentId && issue.assigneeAgentId !== runCtx.agentId) {
15457
15460
  throw new Error("The selected Paperclip issue is assigned to another agent.");
15458
15461
  }
15459
15462
  await ctx.issues.assertCheckoutOwner({
@@ -15462,7 +15465,7 @@ function registerGitHubAgentTools(ctx) {
15462
15465
  actorAgentId: runCtx.agentId,
15463
15466
  actorRunId: runCtx.runId
15464
15467
  });
15465
- const executionWorkspaceId = normalizeOptionalToolString(issueLinkScope.issue.executionWorkspaceId);
15468
+ const executionWorkspaceId = normalizeOptionalToolString(issue.executionWorkspaceId);
15466
15469
  if (!executionWorkspaceId) {
15467
15470
  throw new Error("The selected Paperclip issue does not have an execution workspace for branch publication.");
15468
15471
  }
@@ -15475,9 +15478,15 @@ function registerGitHubAgentTools(ctx) {
15475
15478
  throw new Error("The selected Paperclip issue execution workspace is not locally realized.");
15476
15479
  }
15477
15480
  const workspaceRepository = workspace.repoUrl ? parseRepositoryReference(workspace.repoUrl) : null;
15478
- const repository = issueLinkScope.repository;
15481
+ const repository = explicitRepository ? parseRepositoryReference(explicitRepository) : (await resolveIssueGitHubLinkMapping(ctx, {
15482
+ companyId: runCtx.companyId,
15483
+ issueId: paperclipIssueId
15484
+ })).repository;
15485
+ if (!repository) {
15486
+ throw new Error(`Invalid GitHub repository: ${explicitRepository}. Use owner/repo or https://github.com/owner/repo.`);
15487
+ }
15479
15488
  if (!workspaceRepository || !areRepositoriesEqual(workspaceRepository, repository)) {
15480
- throw new Error("The execution workspace repository does not match the GitHub repository mapped to this Paperclip issue.");
15489
+ throw new Error("The execution workspace repository does not match the selected GitHub repository.");
15481
15490
  }
15482
15491
  const githubToken = (await resolveGithubToken(ctx, { companyId: runCtx.companyId })).trim();
15483
15492
  if (!githubToken) {
@@ -15540,15 +15549,10 @@ function registerGitHubAgentTools(ctx) {
15540
15549
  pullRequestData = existingPullRequest;
15541
15550
  }
15542
15551
  if (paperclipIssueId) {
15543
- const linkScope = issueLinkScope ?? await resolveIssueGitHubLinkMapping(ctx, {
15544
- companyId: runCtx.companyId,
15545
- issueId: paperclipIssueId,
15546
- repositoryUrl: repository.url
15547
- });
15548
15552
  const pullRequestUrl = normalizeGitHubPullRequestHtmlUrl(pullRequestData.html_url) ?? `${repository.url}/pull/${pullRequestData.number}`;
15549
15553
  await upsertGitHubPullRequestLinkRecord(ctx, {
15550
15554
  companyId: runCtx.companyId,
15551
- projectId: linkScope.mapping.paperclipProjectId ?? linkScope.projectId,
15555
+ projectId: issueProjectId,
15552
15556
  issueId: paperclipIssueId,
15553
15557
  repositoryUrl: repository.url,
15554
15558
  pullRequestNumber: pullRequestData.number,
@@ -15561,7 +15565,7 @@ function registerGitHubAgentTools(ctx) {
15561
15565
  });
15562
15566
  invalidateProjectPullRequestCaches({
15563
15567
  companyId: runCtx.companyId,
15564
- projectId: linkScope.mapping.paperclipProjectId ?? linkScope.projectId,
15568
+ projectId: issueProjectId,
15565
15569
  repository
15566
15570
  });
15567
15571
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",