feat(coding-agent): add experimental feature guard (#5547)

This commit is contained in:
Vegard Stikbakke
2026-06-09 13:23:07 +02:00
committed by GitHub
parent 28c83e8385
commit 66335d3a49
4 changed files with 49 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
### Added
- Added `areExperimentalFeaturesEnabled` feature guard to allow users to opt-in to early features.
- Added `ctx.isProjectTrusted()` for extensions to observe the effective project trust decision, including temporary trust decisions ([#5523](https://github.com/earendil-works/pi/issues/5523)).
### Fixed

View File

@@ -0,0 +1,3 @@
export function areExperimentalFeaturesEnabled(): boolean {
return process.env.PI_EXPERIMENTAL === "1";
}

View File

@@ -28,6 +28,7 @@ export {
export { type BashExecutorOptions, type BashResult, executeBashWithOperations } from "./bash-executor.ts";
export type { CompactionResult } from "./compaction/index.ts";
export { createEventBus, type EventBus, type EventBusController } from "./event-bus.ts";
export { areExperimentalFeaturesEnabled } from "./experimental.ts";
// Extensions system
export {
type AgentEndEvent,

View File

@@ -0,0 +1,44 @@
import { afterEach, describe, expect, it } from "vitest";
import { areExperimentalFeaturesEnabled } from "../src/core/experimental.ts";
describe("areExperimentalFeaturesEnabled", () => {
const originalPiExperimental = process.env.PI_EXPERIMENTAL;
afterEach(() => {
if (originalPiExperimental === undefined) {
delete process.env.PI_EXPERIMENTAL;
} else {
process.env.PI_EXPERIMENTAL = originalPiExperimental;
}
});
it("returns false when PI_EXPERIMENTAL is unset", () => {
delete process.env.PI_EXPERIMENTAL;
expect(areExperimentalFeaturesEnabled()).toBe(false);
});
it("returns false when PI_EXPERIMENTAL is empty", () => {
process.env.PI_EXPERIMENTAL = "";
expect(areExperimentalFeaturesEnabled()).toBe(false);
});
it("returns true when PI_EXPERIMENTAL is set to 1", () => {
process.env.PI_EXPERIMENTAL = "1";
expect(areExperimentalFeaturesEnabled()).toBe(true);
});
it("returns false when PI_EXPERIMENTAL is set to 0", () => {
process.env.PI_EXPERIMENTAL = "0";
expect(areExperimentalFeaturesEnabled()).toBe(false);
});
it("returns false when PI_EXPERIMENTAL is set to a non-1 value", () => {
process.env.PI_EXPERIMENTAL = "true";
expect(areExperimentalFeaturesEnabled()).toBe(false);
});
});