@henryqw/pi-herdr-done 2.0.2 → 2.0.3
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/extensions/done.ts +5 -7
- package/package.json +1 -1
package/extensions/done.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { tmpdir } from "node:os";
|
|
2
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ExecResult, ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { createHerdrClient, withWorktreeLock } from "@henryqw/pi-herdr";
|
|
4
4
|
|
|
5
|
-
type ExecResult = { stdout: string; stderr: string; code: number; killed?: boolean };
|
|
6
|
-
|
|
7
5
|
type SnapshotPane = { tab_id?: unknown; cwd?: unknown };
|
|
8
6
|
type TabEntry = { tab_id?: unknown; workspace_id?: unknown; label?: unknown };
|
|
9
7
|
|
|
@@ -11,7 +9,7 @@ export default function herdrDoneExtension(pi: ExtensionAPI): void {
|
|
|
11
9
|
const herdr = createHerdrClient<{ cwd: string }>(pi.exec.bind(pi));
|
|
12
10
|
|
|
13
11
|
const execOrThrow = async (command: string, args: string[], cwd: string): Promise<string> => {
|
|
14
|
-
const result = await pi.exec(command, args, { cwd })
|
|
12
|
+
const result: ExecResult = await pi.exec(command, args, { cwd });
|
|
15
13
|
if (result.code !== 0 || result.killed) {
|
|
16
14
|
throw new Error(`${command} ${args[0]} failed: ${result.stderr.trim() || "killed"}`);
|
|
17
15
|
}
|
|
@@ -47,8 +45,7 @@ export default function herdrDoneExtension(pi: ExtensionAPI): void {
|
|
|
47
45
|
const parentIsBare = mainCheckout !== checkout &&
|
|
48
46
|
worktreeFields.slice(1, worktreeFields.indexOf("")).includes("bare");
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
await withWorktreeLock(checkout, async () => {
|
|
48
|
+
const siblingTabIds = await withWorktreeLock(checkout, async () => {
|
|
52
49
|
// With --force, skip the dependents check entirely and let git remove the checkout.
|
|
53
50
|
let dependentIds: string[] = [];
|
|
54
51
|
if (option !== "--force") {
|
|
@@ -69,7 +66,7 @@ export default function herdrDoneExtension(pi: ExtensionAPI): void {
|
|
|
69
66
|
if (tabsById.get(tabId)?.workspace_id !== workspaceId) {
|
|
70
67
|
throw new Error(`Herdr tab ${tabId} does not belong to workspace ${workspaceId}.`);
|
|
71
68
|
}
|
|
72
|
-
siblingTabIds = validTabs
|
|
69
|
+
const siblingTabIds = validTabs
|
|
73
70
|
.filter((tab) => tab.tab_id !== tabId && tab.workspace_id === workspaceId)
|
|
74
71
|
.map((tab) => tab.tab_id);
|
|
75
72
|
const blockers = dependentIds.filter((id) => tabsById.get(id)?.workspace_id !== workspaceId);
|
|
@@ -84,6 +81,7 @@ export default function herdrDoneExtension(pi: ExtensionAPI): void {
|
|
|
84
81
|
await execOrThrow("git", [
|
|
85
82
|
"worktree", "remove", ...(option === "--force" ? ["--force"] : []), checkout,
|
|
86
83
|
], ctx.cwd);
|
|
84
|
+
return siblingTabIds;
|
|
87
85
|
});
|
|
88
86
|
try {
|
|
89
87
|
await Promise.all(siblingTabIds.map((id) => herdr.run(["tab", "close", id], { cwd: tmpdir() })));
|