pi-petrroll 0.2.1 → 0.2.2

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
@@ -85,7 +85,7 @@ Manual `/cd` switches without starting another model response; the agent tool re
85
85
  - A new session ID and session file are created for the destination, using Pi's `SessionManager.forkFrom()`.
86
86
  - The original session is left in place. The full conversation tree is copied, and the currently selected branch is preserved.
87
87
  - Pi's native session replacement rebuilds built-in tools, the working-directory display, settings, extensions, skills, and project context such as `AGENTS.md` for the destination.
88
- - `pi -c` from the destination can continue the copied session. Copies use Pi's normal per-directory session storage (respecting `PI_CODING_AGENT_DIR`), not a source session's explicit `--session-dir` or `PI_CODING_AGENT_SESSION_DIR` override. If you use those overrides, resume the copy by its file path or remove the override.
88
+ - `pi -c` from the destination can continue the copied session. Copies stay in the source session's storage: if it uses a custom session directory (`--session-dir`, `PI_CODING_AGENT_SESSION_DIR`, or the `sessionDir` setting), the copy is written there too, so `pi --session <id>` and `/resume` find it under the same override. Otherwise copies use Pi's normal per-directory storage for the destination (respecting `PI_CODING_AGENT_DIR`).
89
89
  - No `process.chdir()` trick, built-in tool overrides, or Pi internals are patched. Your parent terminal's working directory does **not** change.
90
90
 
91
91
  ### Safety and limitations
@@ -39,6 +39,20 @@ function requireSavedSession(ctx: ExtensionContext): string {
39
39
  return file;
40
40
  }
41
41
 
42
+ /**
43
+ * Where the copied session should live. A custom session dir (--session-dir,
44
+ * PI_CODING_AGENT_SESSION_DIR, or the sessionDir setting) is shared across
45
+ * projects and must be kept; otherwise resume/listing in that dir cannot find
46
+ * the copy. The default dir is per-cwd, so the copy gets the target's default.
47
+ */
48
+ export function targetSessionDir(sessionManager: ExtensionContext["sessionManager"]): string | undefined {
49
+ // The live object is a full SessionManager; ReadonlySessionManager just does
50
+ // not expose this predicate in its type.
51
+ const usesDefault = (sessionManager as { usesDefaultSessionDir?: () => boolean }).usesDefaultSessionDir;
52
+ if (typeof usesDefault !== "function" || usesDefault.call(sessionManager)) return undefined;
53
+ return sessionManager.getSessionDir();
54
+ }
55
+
42
56
  export default function cdExtension(pi: ExtensionAPI) {
43
57
  let busy = false;
44
58
  let toolRequest: { argument: string; signal: AbortSignal | undefined } | undefined;
@@ -66,7 +80,7 @@ export default function cdExtension(pi: ExtensionAPI) {
66
80
  return;
67
81
  }
68
82
 
69
- const copy = SessionManager.forkFrom(source, target);
83
+ const copy = SessionManager.forkFrom(source, target, targetSessionDir(ctx.sessionManager));
70
84
  // forkFrom copies the whole tree but opens its last entry. Preserve the
71
85
  // actual selected leaf, including when the user navigated with /tree.
72
86
  const leaf = ctx.sessionManager.getLeafId();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-petrroll",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Small, focused Pi extensions by petrroll: switch projects and track external costs in your session.",
5
5
  "type": "module",
6
6
  "license": "MIT",