@henryqw/pi-herdr-clone 0.2.2 → 0.2.4

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.
@@ -194,8 +194,7 @@ async function launchCloneAgent(
194
194
  }
195
195
 
196
196
  export default function herdrCloneExtension(pi: ExtensionAPI): void {
197
- const herdr = createHerdrClient<{ cwd: string }>((command, args, options) =>
198
- pi.exec(command, [...args], options));
197
+ const herdr = createHerdrClient<{ cwd: string }>(pi.exec.bind(pi));
199
198
 
200
199
  pi.registerCommand("clone-tab", {
201
200
  description: "Clone the current conversation path into a new Herdr tab",
@@ -212,28 +211,20 @@ export default function herdrCloneExtension(pi: ExtensionAPI): void {
212
211
  return { createdTab, cloneFile };
213
212
  };
214
213
  const { createdTab, cloneFile } = source.checkout ? await withWorktreeLock(source.checkout, mutate) : await mutate();
215
- let tabId: string | undefined;
216
- let rootPaneId: string | undefined;
214
+ let tab: ReturnType<typeof parseCreatedTab>;
217
215
  try {
218
- const tabResponse: unknown = JSON.parse(createdTab.stdout);
219
- if (!tabResponse || typeof tabResponse !== "object" || Array.isArray(tabResponse)) {
220
- throw new Error("Herdr tab create returned invalid JSON");
221
- }
222
- const result = (tabResponse as {
223
- result?: { tab?: { tab_id?: unknown }; root_pane?: { pane_id?: unknown } };
224
- }).result;
225
- tabId = requiredString(result?.tab?.tab_id, "Herdr tab response tab_id");
226
- rootPaneId = requiredString(result?.root_pane?.pane_id, `Herdr tab ${tabId} root pane_id`);
216
+ tab = parseCreatedTab(createdTab, source.workspaceId);
227
217
  } catch (error) {
228
218
  throw new Error(
229
- `Clone launch could not be confirmed after creating a Herdr tab; retained${tabId ? ` Herdr tab ${tabId} and` : ""} session ${cloneFile}: ${errorMessage(error)}`,
219
+ `Clone launch could not be confirmed after creating a Herdr tab; retained session ${cloneFile}: ${errorMessage(error)}`,
230
220
  { cause: error },
231
221
  );
232
222
  }
233
- const agentName = await launchCloneAgent(herdr, ctx, rootPaneId!, cloneFile, `Herdr tab ${tabId}, root pane ${rootPaneId}, and session ${cloneFile}`);
223
+ const { tabId, rootPaneId } = tab;
224
+ const agentName = await launchCloneAgent(herdr, ctx, rootPaneId, cloneFile, `Herdr tab ${tabId}, root pane ${rootPaneId}, and session ${cloneFile}`);
234
225
 
235
226
  try {
236
- await herdr.run(["tab", "focus", tabId!], { cwd: ctx.cwd });
227
+ await herdr.run(["tab", "focus", tabId], { cwd: ctx.cwd });
237
228
  } catch (error) {
238
229
  ctx.ui.notify(
239
230
  `Clone agent ${agentName} started in Herdr tab ${tabId} (root pane ${rootPaneId}), but focus failed: ${errorMessage(error)}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-herdr-clone",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Clone the current Pi conversation path into a new Herdr tab.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -28,7 +28,7 @@
28
28
  "@earendil-works/pi-coding-agent": "^0.84.2"
29
29
  },
30
30
  "dependencies": {
31
- "@henryqw/pi-herdr": "^0.2.0"
31
+ "@henryqw/pi-herdr": "^0.3.0"
32
32
  },
33
33
  "repository": {
34
34
  "type": "git",