paperclip-github-plugin 0.15.0 → 0.15.1

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 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.
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; if omitted, the issue project must have exactly one mapped repository. By default the tool uses the execution-workspace root as the local Git checkout. For general-purpose workspaces that contain several repositories, `workspaceRelativePath` selects a checkout below that trusted root, with realpath containment enforced. 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 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.
244
+ 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.
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
@@ -262,7 +262,11 @@ var GITHUB_AGENT_TOOLS = [
262
262
  properties: {
263
263
  repository: {
264
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."
265
+ description: "Target GitHub repository as owner/repo or https://github.com/owner/repo. It may be outside Paperclip repository mappings. Omit only when the issue project has exactly one mapped repository."
266
+ },
267
+ workspaceRelativePath: {
268
+ type: "string",
269
+ description: "Optional path to the local Git checkout, relative to the trusted issue execution workspace. Use this when a general-purpose workspace contains the target repository in a subdirectory."
266
270
  },
267
271
  paperclipIssueId: {
268
272
  type: "string",
@@ -644,7 +648,7 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
644
648
  var require2 = createRequire(import.meta.url);
645
649
  var packageJson = require2("../package.json");
646
650
  var SCHEDULE_TICK_CRON = "* * * * *";
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";
651
+ var MANIFEST_VERSION = "0.15.1"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
648
652
  var manifest = {
649
653
  id: GITHUB_SYNC_PLUGIN_ID,
650
654
  apiVersion: 1,
package/dist/worker.js CHANGED
@@ -3,7 +3,7 @@ import { Buffer as Buffer2 } from "node:buffer";
3
3
  import { realpathSync } from "node:fs";
4
4
  import { chmod, mkdir as mkdir2, readFile, writeFile } from "node:fs/promises";
5
5
  import { homedir } from "node:os";
6
- import { dirname, join as join2, resolve as resolve2 } from "node:path";
6
+ import { dirname, isAbsolute as isAbsolute2, join as join2, relative, resolve as resolve2 } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { Octokit } from "@octokit/rest";
9
9
  import {
@@ -272,7 +272,11 @@ var GITHUB_AGENT_TOOLS = [
272
272
  properties: {
273
273
  repository: {
274
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."
275
+ description: "Target GitHub repository as owner/repo or https://github.com/owner/repo. It may be outside Paperclip repository mappings. Omit only when the issue project has exactly one mapped repository."
276
+ },
277
+ workspaceRelativePath: {
278
+ type: "string",
279
+ description: "Optional path to the local Git checkout, relative to the trusted issue execution workspace. Use this when a general-purpose workspace contains the target repository in a subdirectory."
276
280
  },
277
281
  paperclipIssueId: {
278
282
  type: "string",
@@ -15128,6 +15132,21 @@ async function startSync(ctx, trigger, options = {}) {
15128
15132
  return getActiveOrCurrentSyncState(ctx);
15129
15133
  }
15130
15134
  }
15135
+ function resolveTrustedWorkspacePath(workspacePath, workspaceRelativePath) {
15136
+ if (!workspaceRelativePath) {
15137
+ return workspacePath;
15138
+ }
15139
+ const trustedRoot = realpathSync(workspacePath);
15140
+ if (isAbsolute2(workspaceRelativePath)) {
15141
+ throw new Error("workspaceRelativePath must be relative to the trusted execution workspace.");
15142
+ }
15143
+ const candidate = realpathSync(resolve2(trustedRoot, workspaceRelativePath));
15144
+ const relativeCandidate = relative(trustedRoot, candidate);
15145
+ if (relativeCandidate === ".." || relativeCandidate.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute2(relativeCandidate)) {
15146
+ throw new Error("workspaceRelativePath must stay inside the trusted execution workspace.");
15147
+ }
15148
+ return candidate;
15149
+ }
15131
15150
  function registerGitHubAgentTools(ctx) {
15132
15151
  async function createAgentToolOctokit(runCtx, toolName, repository) {
15133
15152
  return createGitHubToolOctokit(ctx, runCtx.companyId, {
@@ -15441,6 +15460,7 @@ function registerGitHubAgentTools(ctx) {
15441
15460
  const input = getToolInputRecord(params);
15442
15461
  const paperclipIssueId = normalizeOptionalToolString(input.paperclipIssueId);
15443
15462
  const explicitRepository = normalizeOptionalToolString(input.repository);
15463
+ const workspaceRelativePath = normalizeOptionalToolString(input.workspaceRelativePath);
15444
15464
  const head = normalizeOptionalToolString(input.head);
15445
15465
  const headCommitSha = normalizeOptionalToolString(input.headCommitSha);
15446
15466
  const base = normalizeOptionalToolString(input.base);
@@ -15477,7 +15497,7 @@ function registerGitHubAgentTools(ctx) {
15477
15497
  if (!workspacePath) {
15478
15498
  throw new Error("The selected Paperclip issue execution workspace is not locally realized.");
15479
15499
  }
15480
- const workspaceRepository = workspace.repoUrl ? parseRepositoryReference(workspace.repoUrl) : null;
15500
+ const publicationWorkspacePath = resolveTrustedWorkspacePath(workspacePath, workspaceRelativePath);
15481
15501
  const repository = explicitRepository ? parseRepositoryReference(explicitRepository) : (await resolveIssueGitHubLinkMapping(ctx, {
15482
15502
  companyId: runCtx.companyId,
15483
15503
  issueId: paperclipIssueId
@@ -15485,15 +15505,12 @@ function registerGitHubAgentTools(ctx) {
15485
15505
  if (!repository) {
15486
15506
  throw new Error(`Invalid GitHub repository: ${explicitRepository}. Use owner/repo or https://github.com/owner/repo.`);
15487
15507
  }
15488
- if (!workspaceRepository || !areRepositoriesEqual(workspaceRepository, repository)) {
15489
- throw new Error("The execution workspace repository does not match the selected GitHub repository.");
15490
- }
15491
15508
  const githubToken = (await resolveGithubToken(ctx, { companyId: runCtx.companyId })).trim();
15492
15509
  if (!githubToken) {
15493
15510
  throw new Error(MISSING_GITHUB_TOKEN_SYNC_MESSAGE);
15494
15511
  }
15495
15512
  const publishedBranch = await createPullRequestBranchPublisher({
15496
- workspacePath,
15513
+ workspacePath: publicationWorkspacePath,
15497
15514
  repositoryUrl: repository.url,
15498
15515
  branchName: head,
15499
15516
  expectedCommitSha: headCommitSha,
@@ -16149,6 +16166,7 @@ var __testing = {
16149
16166
  resolveGithubToken,
16150
16167
  resolvePaperclipPullRequestIssueStatus,
16151
16168
  resolveSyncTransitionAssignee,
16169
+ resolveTrustedWorkspacePath,
16152
16170
  setCreatePullRequestBranchPublisher(publisher) {
16153
16171
  createPullRequestBranchPublisher = publisher ?? publishLocalBranchForPullRequest;
16154
16172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",