Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions scripts/agents/planner.agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,19 @@ function generatePlan(context) {
**Confidence:** ${context.projectAssignment.confidence}
**Reason:** ${context.projectAssignment.reason}
`;
return plan.replace(
/---\r?\n\*\*Generated by Planner Agent\*\*.*/,
`${projectSection.trimStart()}
---
**Generated by Planner Agent** <!-- planner-agent-summary -->`,
);
const marker = "<!-- planner-agent-summary -->";
const markerIndex = plan.indexOf(marker);
if (markerIndex !== -1) {
const footerIndex = plan.lastIndexOf("---", markerIndex);
if (footerIndex !== -1) {
return (
plan.slice(0, footerIndex) +
projectSection.trimStart() +
"\n" +
plan.slice(footerIndex)
);
}
}
}

return plan;
Expand Down
22 changes: 18 additions & 4 deletions tests/jest.setup.localstorage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Jest Setup: localStorage polyfill
* Provides localStorage mock for jsdom test environment
* Jest Setup: Node.js built-ins polyfill
* Provides polyfills for Node.js built-ins in jsdom test environment
*
* @fileoverview localStorage polyfill for jest/jsdom tests
* @fileoverview Built-ins polyfills for jest/jsdom tests
* @author LightSpeedWP Team
* @version 1.0.0
* @version 1.1.0
*/

// Polyfill TextDecoder and TextEncoder for test environments that don't have them
Expand All @@ -24,3 +24,17 @@ if (typeof global.localStorage === "undefined") {
};
global.localStorage = localStorageMock;
}

// Polyfill TextDecoder and TextEncoder for ESM modules using @actions/core
if (
typeof global.TextDecoder === "undefined" ||
typeof global.TextEncoder === "undefined"
) {
const { TextDecoder, TextEncoder } = require("util");
if (typeof global.TextDecoder === "undefined") {
global.TextDecoder = TextDecoder;
}
if (typeof global.TextEncoder === "undefined") {
global.TextEncoder = TextEncoder;
}
}
Loading