From fb99c45a306fa3cb1704011b477d3ffa28652afd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 06:21:39 +0000 Subject: [PATCH 1/4] chore(deps-dev): bump the development-minor-patch group across 1 directory with 2 updates Bumps the development-minor-patch group with 2 updates in the / directory: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [typebox](https://github.com/sinclairzx81/typebox). Updates `@types/node` from 22.20.2 to 22.20.5 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `typebox` from 1.3.31 to 1.3.34 - [Commits](https://github.com/sinclairzx81/typebox/compare/1.3.31...1.3.34) --- updated-dependencies: - dependency-name: "@types/node" dependency-version: 22.20.5 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: development-minor-patch - dependency-name: typebox dependency-version: 1.3.34 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: development-minor-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 16 ++++++++-------- package.json | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e11a4d..3266e58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "license": "MIT", "devDependencies": { "@earendil-works/pi-coding-agent": "0.85.1", - "@types/node": "22.20.2", - "typebox": "1.3.31", + "@types/node": "22.20.5", + "typebox": "1.3.34", "typescript": "7.0.2", "yaml": "2.9.1" }, @@ -2417,9 +2417,9 @@ } }, "node_modules/@types/node": { - "version": "22.20.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.2.tgz", - "integrity": "sha512-xlvWf4Vs9n1PEVYwP1n4vvG07M6y8WgvJ2t0vbrWTmijsIHp1cS+uJ2kMIRdY3nHZK0nCYKrPeD171+SzF4/zw==", + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", "dev": true, "license": "MIT", "dependencies": { @@ -2767,9 +2767,9 @@ } }, "node_modules/typebox": { - "version": "1.3.31", - "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.31.tgz", - "integrity": "sha512-7++UxOb7lAJbJ8pbhN2Yl/ljadShbHZ6GQwst/YEUAlVh1nP8LqYpC2t+R1VysunFpmDffDzhZRsvGchx0PqUA==", + "version": "1.3.34", + "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.34.tgz", + "integrity": "sha512-wbnzrXXDW8xEFHDZZs2jo1MkhaYlKAY4FRhpBc1+2LF1fZVBGCXGdLEhA/Z/NBbgzJMFfeM8m7elKPa/+KxaUQ==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index 6c2511c..de0dfe2 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ }, "devDependencies": { "@earendil-works/pi-coding-agent": "0.85.1", - "@types/node": "22.20.2", - "typebox": "1.3.31", + "@types/node": "22.20.5", + "typebox": "1.3.34", "typescript": "7.0.2", "yaml": "2.9.1" } From 7b59d39e68785d032b95d6c7c03eaaea6f75a9d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Oct 2026 19:03:40 +0000 Subject: [PATCH 2/4] ci: bump the actions-minor-patch group with 3 updates Bumps the actions-minor-patch group with 3 updates: [actions/setup-node](https://github.com/actions/setup-node), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `actions/setup-node` from 7.0.0 to 7.1.0 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/820762786026740c76f36085b0efc47a31fe5020...949feb2413d6458794dcd2491c4babbbce0c15c1) Updates `actions/upload-artifact` from 7.0.1 to 7.0.2 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/043fb46d1a93c77aae656e7c1c64a875d1fc6a0a...cf430e030ddbb5b0abf93d22962f4752f3646cd9) Updates `actions/download-artifact` from 8.0.1 to 8.0.2 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c...9000827ccba6bdab643e8b6fd33ac0654aef8333) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions-minor-patch - dependency-name: actions/upload-artifact dependency-version: 7.0.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions-minor-patch - dependency-name: actions/download-artifact dependency-version: 8.0.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions-minor-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 10 +++++----- .github/workflows/release.yml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7526e1e..210786a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: with: ref: ${{ inputs.ref || github.sha }} persist-credentials: false - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: ${{ matrix.node }} cache: npm @@ -79,7 +79,7 @@ jobs: with: ref: ${{ inputs.ref || github.sha }} persist-credentials: false - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '24' cache: npm @@ -105,7 +105,7 @@ jobs: with: ref: ${{ inputs.ref || github.sha }} persist-credentials: false - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '24' cache: npm @@ -124,7 +124,7 @@ jobs: with: ref: ${{ inputs.ref || github.sha }} persist-credentials: false - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '24' cache: npm @@ -132,7 +132,7 @@ jobs: - run: npm run build - id: name run: echo "artifact=package-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT" - - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ steps.name.outputs.artifact }} path: dist/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc03ae3..1b9ca2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -109,12 +109,12 @@ jobs: # The publishing tools come from this trusted main workflow, not an artifact. ref: ${{ github.sha }} persist-credentials: false - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '24' registry-url: https://registry.npmjs.org package-manager-cache: false - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: ${{ needs.verify.outputs.artifact }} path: dist From 6ca9b3324b3d558a74399d398d30f16af560861f Mon Sep 17 00:00:00 2001 From: btnalit Date: Thu, 22 Oct 2026 23:28:58 -0700 Subject: [PATCH 3/4] fix: adapt before_agent_start prompt extraction and child process detection for modern Pi --- src/child-process.test.ts | 13 +++++++++++++ src/child-process.ts | 15 +++++++++++++-- src/index.test.ts | 15 +++++++++++++++ src/index.ts | 7 ++++++- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/child-process.test.ts b/src/child-process.test.ts index 887f5cb..05f3b08 100644 --- a/src/child-process.test.ts +++ b/src/child-process.test.ts @@ -14,8 +14,21 @@ describe("isSubagentProcess", () => { ); }); + test("returns true when PI_SUBAGENT_CHILD is set to 1", () => { + assert.equal(isSubagentProcess({ PI_SUBAGENT_CHILD: "1" }), true); + }); + + test("returns false when PI_SUBAGENT_CHILD is set to 0", () => { + assert.equal(isSubagentProcess({ PI_SUBAGENT_CHILD: "0" }), false); + }); + + test("returns true when PI_SUBAGENT_RUNNER_PID is set", () => { + assert.equal(isSubagentProcess({ PI_SUBAGENT_RUNNER_PID: "4321" }), true); + }); + test("returns false when the subagent env var is an empty string", () => { assert.equal(isSubagentProcess({ PI_SUBAGENT_AGENT_ID: "" }), false); + assert.equal(isSubagentProcess({ PI_SUBAGENT_RUNNER_PID: "" }), false); }); test("ignores unrelated env vars", () => { diff --git a/src/child-process.ts b/src/child-process.ts index 56f1f5f..bdb714a 100644 --- a/src/child-process.ts +++ b/src/child-process.ts @@ -1,8 +1,19 @@ -/** Environment variable set by run-subagent on child agent processes. */ +/** + * Environment variables set on child agent processes: + * - PI_SUBAGENT_AGENT_ID: Legacy runner identification. + * - PI_SUBAGENT_CHILD: Modern pi-subagents standard (set to "1"). + * - PI_SUBAGENT_RUNNER_PID: Detached background runner process. + */ const SUBAGENT_AGENT_ID_ENV = "PI_SUBAGENT_AGENT_ID"; +const SUBAGENT_CHILD_ENV = "PI_SUBAGENT_CHILD"; +const SUBAGENT_RUNNER_PID_ENV = "PI_SUBAGENT_RUNNER_PID"; /** Returns true when the current process is a child subagent process. */ export function isSubagentProcess(env: NodeJS.ProcessEnv): boolean { const agentId = env[SUBAGENT_AGENT_ID_ENV]; - return agentId !== undefined && agentId !== ""; + if (agentId !== undefined && agentId !== "") return true; + if (env[SUBAGENT_CHILD_ENV] === "1") return true; + const runnerPid = env[SUBAGENT_RUNNER_PID_ENV]; + if (runnerPid !== undefined && runnerPid !== "") return true; + return false; } diff --git a/src/index.test.ts b/src/index.test.ts index 0fa4e70..cb19bd1 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -29,6 +29,21 @@ test('factory has no filesystem writes; five relevant hooks, no approval/signal test('subagent factory registers nothing and never creates state',()=>fixture(async({stateDir,hooks})=>{ assert.equal(hooks.size,0);assert.equal(existsSync(stateDir),false); },undefined,{PI_SUBAGENT_AGENT_ID:'child'})); +test('subagent factory registers nothing when PI_SUBAGENT_CHILD or PI_SUBAGENT_RUNNER_PID is set',async()=>{ + await fixture(async({hooks})=>{ assert.equal(hooks.size,0); },undefined,{PI_SUBAGENT_CHILD:'1'}); + await fixture(async({hooks})=>{ assert.equal(hooks.size,0); },undefined,{PI_SUBAGENT_RUNNER_PID:'9999'}); +}); +test('before_agent_start handles missing prompt, custom messages and content-block arrays safely',()=>fixture(async({call})=>{ + await call('session_compact',compact()); + // Custom message without prompt property + assert.equal(await call('before_agent_start',{messageType:'custom',message:{role:'user',content:'test'},systemPrompt:'Base'}),undefined); + // Undefined / empty prompt + assert.equal(await call('before_agent_start',{prompt:'',systemPrompt:'Base'}),undefined); + assert.equal(await call('before_agent_start',{systemPrompt:'Base'}),undefined); + // Array content blocks + const arrayResult = await call('before_agent_start',{prompt:[{type:'text',text:'Database port'}],systemPrompt:'Base prompt'}); + assert.match(arrayResult.systemPrompt,/5432/); +})); test('compaction automatically persists and recall follows the topic across directories and sessions',()=>fixture(async({stateDir,call,ctx})=>{ await call('session_compact',compact()); const result=await call('before_agent_start',{prompt:'Database port',systemPrompt:'Base prompt'}); diff --git a/src/index.ts b/src/index.ts index e7a5be3..20e7434 100644 --- a/src/index.ts +++ b/src/index.ts @@ -169,7 +169,12 @@ export default async function memoryEvolution(pi: ExtensionAPI, dependencies: Me })); pi.on("before_agent_start", guard((event, ctx) => { lastRecall = 'Last automatic recall failed before completing; see /memory status.'; - const query = resolveRecallQuery(event.prompt, recentUserMessages(ctx)); + const rawPrompt = 'prompt' in event ? event.prompt : undefined; + const promptText = typeof rawPrompt === 'string' ? rawPrompt + : Array.isArray(rawPrompt) ? (rawPrompt as { type?: string; text?: string }[]).filter(b => b?.type === 'text' && typeof b?.text === 'string').map(b => b.text).join('\n') + : ''; + if (!promptText.trim()) return; + const query = resolveRecallQuery(promptText, recentUserMessages(ctx)); const { selected, diagnostics } = retrieveMemories(query.query ? getStore().readMemories() : [], query); const digest = buildRuntimeDigest(selected, query); lastRecall = diagnosticText({ ...diagnostics, injected: digest?.split('\n').filter(line => line.startsWith('{')).length ?? 0, From 05d55bc7f28ca1f53c9bdc1053dce704f6860811 Mon Sep 17 00:00:00 2001 From: btnalit Date: Thu, 22 Oct 2026 23:39:27 -0700 Subject: [PATCH 4/4] fix: add dependency overrides for undici and brace-expansion and refine lastRecall timing --- package-lock.json | 67 +++++++++++++++++++++++------------------------ package.json | 4 +++ src/index.ts | 2 +- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e11a4d..90fe5ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "resolved": "https://registry.npmjs.org/@earendil-works/pi-coding-agent/-/pi-coding-agent-0.85.1.tgz", "integrity": "sha512-FGRN+OHbWaefBPGaTggAdLjrIHW+s2PzLyglz/5dfLzb9of7uuXMXYC0fJIeZTw+shS32o2cuQ9jF7YSDuL/oQ==", "dev": true, - "hasShrinkwrap": true, "license": "MIT", "dependencies": { "@earendil-works/chord": "^0.85.1", @@ -1499,16 +1498,6 @@ "node": ">= 14" } }, - "node_modules/@earendil-works/pi-coding-agent/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, "node_modules/@earendil-works/pi-coding-agent/node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -1547,19 +1536,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@earendil-works/pi-coding-agent/node_modules/brace-expansion": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", - "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, "node_modules/@earendil-works/pi-coding-agent/node_modules/buffer-equal-constant-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", @@ -2319,16 +2295,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@earendil-works/pi-coding-agent/node_modules/undici": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.9.0.tgz", - "integrity": "sha512-aWZpUj7XoGonMClx4gdDRfgBjqeA+F473aDmROQQbM9n6PRfK/u1q/a0X4wMTgcHfT8H6fpbt98PFuDUwFg2YA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=22.19.0" - } - }, "node_modules/@earendil-works/pi-coding-agent/node_modules/undici-types": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", @@ -2766,6 +2732,29 @@ "node": ">=16.20.0" } }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, "node_modules/typebox": { "version": "1.3.31", "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.31.tgz", @@ -2808,6 +2797,16 @@ "@typescript/typescript-win32-x64": "7.0.2" } }, + "node_modules/undici": { + "version": "8.12.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", + "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/undici-types": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", diff --git a/package.json b/package.json index 6c2511c..8ec232e 100644 --- a/package.json +++ b/package.json @@ -64,5 +64,9 @@ "typebox": "1.3.31", "typescript": "7.0.2", "yaml": "2.9.1" + }, + "overrides": { + "brace-expansion": "^5.0.12", + "undici": "^8.10.2" } } diff --git a/src/index.ts b/src/index.ts index 20e7434..c8e0d7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -168,12 +168,12 @@ export default async function memoryEvolution(pi: ExtensionAPI, dependencies: Me if (captured) void enqueue(id, ctx); })); pi.on("before_agent_start", guard((event, ctx) => { - lastRecall = 'Last automatic recall failed before completing; see /memory status.'; const rawPrompt = 'prompt' in event ? event.prompt : undefined; const promptText = typeof rawPrompt === 'string' ? rawPrompt : Array.isArray(rawPrompt) ? (rawPrompt as { type?: string; text?: string }[]).filter(b => b?.type === 'text' && typeof b?.text === 'string').map(b => b.text).join('\n') : ''; if (!promptText.trim()) return; + lastRecall = 'Last automatic recall failed before completing; see /memory status.'; const query = resolveRecallQuery(promptText, recentUserMessages(ctx)); const { selected, diagnostics } = retrieveMemories(query.query ? getStore().readMemories() : [], query); const digest = buildRuntimeDigest(selected, query);