pacework 1.7.8 → 1.7.9

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.
@@ -36,7 +36,7 @@ import { automationDenyRules, automationLimits } from "../lib/automation-limits.
36
36
  import { truncateSummary } from "../lib/summary-text.mjs"
37
37
  import { activityForStreamEvent, createActivityTracker, createStreamReader, helpSupportsStreamJson, parseClaudeJsonResult } from "../lib/claude-activity.mjs"
38
38
  import { RUNNER_VERSION } from "../lib/version.mjs"
39
- import { catchUpWithRemote, isPushRefused, pushKeepingRemoteCommits, remoteBranchExists, switchToBranch } from "../lib/branch-sync.mjs"
39
+ import { addBranchWorktree, catchUpWithRemote, isPushRefused, pushKeepingRemoteCommits, remoteBranchExists, switchToBranch } from "../lib/branch-sync.mjs"
40
40
  import { closeSupersededPullRequest } from "../lib/superseded-pr.mjs"
41
41
  import { agentBaseEnv, agentDeniedReads, fenceUntrusted, unsandboxedWarning } from "../lib/agent-env.mjs"
42
42
  import {
@@ -1524,13 +1524,11 @@ async function pushBranchWithToken(worktreePath, branch, githubToken, repo, onRe
1524
1524
  await pushKeepingRemoteCommits({
1525
1525
  exec: gitIn(worktreePath),
1526
1526
  fetch: () => authed(["fetch", "origin", branch]),
1527
- push: () => authed(["push", "--set-upstream", "origin", branch]),
1527
+ push: () => authed(["push", "origin", `HEAD:refs/heads/${branch}`]),
1528
1528
  branch,
1529
1529
  })
1530
1530
  }, {
1531
1531
  onRetry,
1532
- // `--set-upstream` writes the shared config: a lock held by another git
1533
- // process is worth waiting out too.
1534
1532
  isTransient: (error) => isGitLockError(error) || isTransientGitHubFailure(error instanceof Error ? error.message : String(error)),
1535
1533
  })
1536
1534
  } finally {
@@ -1981,7 +1979,7 @@ async function prepareWorktreeCheckout(run, runRepoRoot, worktreePath, branch) {
1981
1979
  const branchAlreadyExists = await branchExists(branch, runRepoRoot)
1982
1980
  if (branchAlreadyExists) {
1983
1981
  // Branch exists from a prior run — reuse it instead of -b
1984
- await execCommand("git", ["-C", runRepoRoot, "worktree", "add", worktreePath, branch], runRepoRoot)
1982
+ await addBranchWorktree(gitIn(runRepoRoot), worktreePath, branch)
1985
1983
  } else {
1986
1984
  // A branch GitHub already has (an open pull request, rework begun on
1987
1985
  // another machine) starts from GitHub's copy, not from main: starting
@@ -12,6 +12,15 @@
12
12
  * throwing, so the caller decides where commands run.
13
13
  */
14
14
 
15
+ /** Use a detached checkout if someone already has the branch checked out. */
16
+ export async function addBranchWorktree(exec, path, branch) {
17
+ let result = await exec(["worktree", "add", path, branch])
18
+ if (result.code !== 0 && /already used by worktree|already checked out at/i.test(result.stderr)) {
19
+ result = await exec(["worktree", "add", "--detach", path, branch])
20
+ }
21
+ if (result.code !== 0) throw new Error(result.stderr || `Could not create a worktree for ${branch}`)
22
+ }
23
+
15
24
  /** Whether `origin/<branch>` exists in this checkout's remote-tracking refs. */
16
25
  export async function remoteBranchExists(exec, branch) {
17
26
  const result = await exec(["rev-parse", "--verify", "--quiet", `refs/remotes/origin/${branch}`])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacework",
3
- "version": "1.7.8",
3
+ "version": "1.7.9",
4
4
  "description": "pacework CLI: connect this machine as a runner for pacework AI agents",
5
5
  "type": "module",
6
6
  "bin": {