@gotgenes/pi-permission-system 5.14.1 → 5.15.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.15.0](https://github.com/gotgenes/pi-permission-system/compare/v5.14.1...v5.15.0) (2026-05-13)
9
+
10
+
11
+ ### Features
12
+
13
+ * add PI_SUBAGENT_PARENT_SESSION convention for parent session resolution ([3829195](https://github.com/gotgenes/pi-permission-system/commit/3829195c7de1f755adf9aa35809de699434d9aae)), closes [#143](https://github.com/gotgenes/pi-permission-system/issues/143)
14
+
15
+
16
+ ### Documentation
17
+
18
+ * add Cross-Extension Integration section to AGENTS.md ([#145](https://github.com/gotgenes/pi-permission-system/issues/145)) ([90209f7](https://github.com/gotgenes/pi-permission-system/commit/90209f75ecd0845b6ac13c6c4895da32a4c82909))
19
+
8
20
  ## [5.14.1](https://github.com/gotgenes/pi-permission-system/compare/v5.14.0...v5.14.1) (2026-05-11)
9
21
 
10
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotgenes/pi-permission-system",
3
- "version": "5.14.1",
3
+ "version": "5.15.0",
4
4
  "description": "Permission enforcement extension for the Pi coding agent.",
5
5
  "type": "module",
6
6
  "files": [
@@ -113,8 +113,9 @@ export async function waitForForwardedPermissionApproval(
113
113
  deps.logger,
114
114
  `Permission forwarding target session could not be resolved. ` +
115
115
  `Checked env vars: ${SUBAGENT_PARENT_SESSION_ENV_CANDIDATES.join(", ")}. ` +
116
- `If you are using nicobailon/pi-subagents or HazAT/pi-interactive-subagents, ` +
117
- `parent-session forwarding is not yet supported for those extensions (see issue #98).`,
116
+ `If you are using a subagent extension (nicobailon/pi-subagents, HazAT/pi-interactive-subagents, etc.), ` +
117
+ `ask its maintainer to set PI_SUBAGENT_PARENT_SESSION in the child process environment ` +
118
+ `(see https://github.com/gotgenes/pi-permission-system/issues/143).`,
118
119
  );
119
120
  return { approved: false, state: "denied" };
120
121
  }
@@ -24,6 +24,9 @@ export const SUBAGENT_ENV_HINT_KEYS = [
24
24
  export const SUBAGENT_PARENT_SESSION_ENV_CANDIDATES: readonly string[] = [
25
25
  // pi-agent-router (original)
26
26
  "PI_AGENT_ROUTER_PARENT_SESSION_ID",
27
+ // Shared convention for CLI-based subagent extensions
28
+ // (nicobailon/pi-subagents, HazAT/pi-interactive-subagents, etc.)
29
+ "PI_SUBAGENT_PARENT_SESSION",
27
30
  ] as const;
28
31
 
29
32
  /** @deprecated Use SUBAGENT_PARENT_SESSION_ENV_CANDIDATES */
@@ -17,6 +17,12 @@ describe("SUBAGENT_PARENT_SESSION_ENV_CANDIDATES", () => {
17
17
  );
18
18
  });
19
19
 
20
+ test("contains PI_SUBAGENT_PARENT_SESSION for CLI-based subagent extensions", () => {
21
+ expect(SUBAGENT_PARENT_SESSION_ENV_CANDIDATES).toContain(
22
+ "PI_SUBAGENT_PARENT_SESSION",
23
+ );
24
+ });
25
+
20
26
  test("deprecated SUBAGENT_PARENT_SESSION_ENV_KEY equals the first candidate", () => {
21
27
  expect(SUBAGENT_PARENT_SESSION_ENV_KEY).toBe(
22
28
  SUBAGENT_PARENT_SESSION_ENV_CANDIDATES[0],
@@ -80,33 +86,31 @@ describe("resolvePermissionForwardingTargetSessionId", () => {
80
86
  ).toBe("parent-session-abc");
81
87
  });
82
88
 
83
- test("isSubagent=true, first candidate absent but second set returns second value", () => {
84
- // Inject a second candidate at test-time to validate the iteration logic
85
- // without waiting for a real extension to adopt the convention.
86
- const originalCandidates = [...SUBAGENT_PARENT_SESSION_ENV_CANDIDATES];
87
- // Mutate the array via index-assignment through a cast so we can test
88
- // multi-candidate iteration without changing the exported constant type.
89
- // This is test-only; production code never mutates the array.
90
- (SUBAGENT_PARENT_SESSION_ENV_CANDIDATES as unknown as string[]).push(
91
- "PI_SUBAGENT_PARENT_SESSION_ID_TEST_ONLY",
92
- );
89
+ test("isSubagent=true, PI_SUBAGENT_PARENT_SESSION resolves when PI_AGENT_ROUTER_PARENT_SESSION_ID is absent", () => {
90
+ expect(
91
+ resolvePermissionForwardingTargetSessionId({
92
+ hasUI: false,
93
+ isSubagent: true,
94
+ currentSessionId: "session-xyz",
95
+ env: {
96
+ PI_SUBAGENT_PARENT_SESSION: "parent-from-convention",
97
+ },
98
+ }),
99
+ ).toBe("parent-from-convention");
100
+ });
93
101
 
94
- try {
95
- expect(
96
- resolvePermissionForwardingTargetSessionId({
97
- hasUI: false,
98
- isSubagent: true,
99
- currentSessionId: "session-xyz",
100
- env: {
101
- PI_SUBAGENT_PARENT_SESSION_ID_TEST_ONLY: "parent-from-second",
102
- },
103
- }),
104
- ).toBe("parent-from-second");
105
- } finally {
106
- // Restore original array contents.
107
- (SUBAGENT_PARENT_SESSION_ENV_CANDIDATES as unknown as string[]).length =
108
- originalCandidates.length;
109
- }
102
+ test("isSubagent=true, PI_AGENT_ROUTER_PARENT_SESSION_ID takes precedence over PI_SUBAGENT_PARENT_SESSION", () => {
103
+ expect(
104
+ resolvePermissionForwardingTargetSessionId({
105
+ hasUI: false,
106
+ isSubagent: true,
107
+ currentSessionId: "session-xyz",
108
+ env: {
109
+ PI_AGENT_ROUTER_PARENT_SESSION_ID: "parent-from-router",
110
+ PI_SUBAGENT_PARENT_SESSION: "parent-from-convention",
111
+ },
112
+ }),
113
+ ).toBe("parent-from-router");
110
114
  });
111
115
 
112
116
  test("isSubagent=true, candidate value is empty string returns null", () => {