@henryqw/pi-herdr-done 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/extensions/done.ts +4 -13
  2. package/package.json +2 -3
@@ -1,7 +1,6 @@
1
1
  import { tmpdir } from "node:os";
2
2
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
- import { createHerdrClient } from "@henryqw/pi-herdr";
4
- import { lock } from "proper-lockfile";
3
+ import { createHerdrClient, withWorktreeLock } from "@henryqw/pi-herdr";
5
4
 
6
5
  type ExecResult = { stdout: string; stderr: string; code: number; killed?: boolean };
7
6
 
@@ -47,8 +46,7 @@ export default function herdrDoneExtension(pi: ExtensionAPI): void {
47
46
  const parentIsBare = mainCheckout !== checkout &&
48
47
  worktreeFields.slice(1, worktreeFields.indexOf("")).includes("bare");
49
48
 
50
- const release = await lock(checkout);
51
- try {
49
+ await withWorktreeLock(checkout, async () => {
52
50
  // With --force, skip the dependents check entirely and let git remove the checkout.
53
51
  if (option !== "--force") {
54
52
  const snapshot = await herdr.json(["api", "snapshot"], { cwd: ctx.cwd });
@@ -78,18 +76,11 @@ export default function herdrDoneExtension(pi: ExtensionAPI): void {
78
76
  await execOrThrow("git", [
79
77
  "worktree", "remove", ...(option === "--force" ? ["--force"] : []), checkout,
80
78
  ], ctx.cwd);
81
- } finally {
82
- await release();
83
- }
79
+ });
84
80
  if (!parentIsBare && mainCheckout !== checkout) {
85
81
  // Serialize concurrent completions pulling the same parent checkout.
86
82
  // Run outside the removed checkout because its directory no longer exists.
87
- const releasePull = await lock(mainCheckout);
88
- try {
89
- await execOrThrow("git", ["pull", "--ff-only"], mainCheckout);
90
- } finally {
91
- await releasePull();
92
- }
83
+ await withWorktreeLock(mainCheckout, () => execOrThrow("git", ["pull", "--ff-only"], mainCheckout));
93
84
  }
94
85
  // Close only this session's tab so unrelated tabs survive.
95
86
  // Run outside the removed checkout because its directory no longer exists.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-herdr-done",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Close and remove the current Herdr worktree from Pi.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -27,8 +27,7 @@
27
27
  "@earendil-works/pi-coding-agent": "^0.84.2"
28
28
  },
29
29
  "dependencies": {
30
- "@henryqw/pi-herdr": "^0.1.2",
31
- "proper-lockfile": "^4.1.2"
30
+ "@henryqw/pi-herdr": "^0.2.0"
32
31
  },
33
32
  "repository": {
34
33
  "type": "git",