experiment: Add feature exp flag for folder trust (#5709)
This commit is contained in:
parent
5cd63a6abc
commit
626844b539
|
@ -1009,6 +1009,39 @@ describe('loadCliConfig ideModeFeature', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('loadCliConfig folderTrustFeature', () => {
|
||||||
|
const originalArgv = process.argv;
|
||||||
|
const originalEnv = { ...process.env };
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.resetAllMocks();
|
||||||
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
||||||
|
process.env.GEMINI_API_KEY = 'test-api-key';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.argv = originalArgv;
|
||||||
|
process.env = originalEnv;
|
||||||
|
vi.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be false by default', async () => {
|
||||||
|
process.argv = ['node', 'script.js'];
|
||||||
|
const settings: Settings = {};
|
||||||
|
const argv = await parseArguments();
|
||||||
|
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
||||||
|
expect(config.getFolderTrustFeature()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be true when settings.folderTrustFeature is true', async () => {
|
||||||
|
process.argv = ['node', 'script.js'];
|
||||||
|
const argv = await parseArguments();
|
||||||
|
const settings: Settings = { folderTrustFeature: true };
|
||||||
|
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
||||||
|
expect(config.getFolderTrustFeature()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
vi.mock('fs', async () => {
|
vi.mock('fs', async () => {
|
||||||
const actualFs = await vi.importActual<typeof fs>('fs');
|
const actualFs = await vi.importActual<typeof fs>('fs');
|
||||||
const MOCK_CWD1 = process.cwd();
|
const MOCK_CWD1 = process.cwd();
|
||||||
|
|
|
@ -313,6 +313,8 @@ export async function loadCliConfig(
|
||||||
const ideModeFeature =
|
const ideModeFeature =
|
||||||
argv.ideModeFeature ?? settings.ideModeFeature ?? false;
|
argv.ideModeFeature ?? settings.ideModeFeature ?? false;
|
||||||
|
|
||||||
|
const folderTrustFeature = settings.folderTrustFeature ?? false;
|
||||||
|
|
||||||
const allExtensions = annotateActiveExtensions(
|
const allExtensions = annotateActiveExtensions(
|
||||||
extensions,
|
extensions,
|
||||||
argv.extensions || [],
|
argv.extensions || [],
|
||||||
|
@ -480,6 +482,7 @@ export async function loadCliConfig(
|
||||||
summarizeToolOutput: settings.summarizeToolOutput,
|
summarizeToolOutput: settings.summarizeToolOutput,
|
||||||
ideMode,
|
ideMode,
|
||||||
ideModeFeature,
|
ideModeFeature,
|
||||||
|
folderTrustFeature,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ export interface Settings {
|
||||||
|
|
||||||
// Flag to be removed post-launch.
|
// Flag to be removed post-launch.
|
||||||
ideModeFeature?: boolean;
|
ideModeFeature?: boolean;
|
||||||
|
folderTrustFeature?: boolean;
|
||||||
/// IDE mode setting configured via slash command toggle.
|
/// IDE mode setting configured via slash command toggle.
|
||||||
ideMode?: boolean;
|
ideMode?: boolean;
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ export interface ConfigParameters {
|
||||||
noBrowser?: boolean;
|
noBrowser?: boolean;
|
||||||
summarizeToolOutput?: Record<string, SummarizeToolOutputSettings>;
|
summarizeToolOutput?: Record<string, SummarizeToolOutputSettings>;
|
||||||
ideModeFeature?: boolean;
|
ideModeFeature?: boolean;
|
||||||
|
folderTrustFeature?: boolean;
|
||||||
ideMode?: boolean;
|
ideMode?: boolean;
|
||||||
loadMemoryFromIncludeDirectories?: boolean;
|
loadMemoryFromIncludeDirectories?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -233,6 +234,7 @@ export class Config {
|
||||||
private readonly extensionContextFilePaths: string[];
|
private readonly extensionContextFilePaths: string[];
|
||||||
private readonly noBrowser: boolean;
|
private readonly noBrowser: boolean;
|
||||||
private readonly ideModeFeature: boolean;
|
private readonly ideModeFeature: boolean;
|
||||||
|
private readonly folderTrustFeature: boolean;
|
||||||
private ideMode: boolean;
|
private ideMode: boolean;
|
||||||
private ideClient: IdeClient;
|
private ideClient: IdeClient;
|
||||||
private inFallbackMode = false;
|
private inFallbackMode = false;
|
||||||
|
@ -305,6 +307,7 @@ export class Config {
|
||||||
this.noBrowser = params.noBrowser ?? false;
|
this.noBrowser = params.noBrowser ?? false;
|
||||||
this.summarizeToolOutput = params.summarizeToolOutput;
|
this.summarizeToolOutput = params.summarizeToolOutput;
|
||||||
this.ideModeFeature = params.ideModeFeature ?? false;
|
this.ideModeFeature = params.ideModeFeature ?? false;
|
||||||
|
this.folderTrustFeature = params.folderTrustFeature ?? false;
|
||||||
this.ideMode = params.ideMode ?? false;
|
this.ideMode = params.ideMode ?? false;
|
||||||
this.ideClient = IdeClient.getInstance();
|
this.ideClient = IdeClient.getInstance();
|
||||||
if (this.ideMode && this.ideModeFeature) {
|
if (this.ideMode && this.ideModeFeature) {
|
||||||
|
@ -638,6 +641,10 @@ export class Config {
|
||||||
return this.ideModeFeature;
|
return this.ideModeFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFolderTrustFeature(): boolean {
|
||||||
|
return this.folderTrustFeature;
|
||||||
|
}
|
||||||
|
|
||||||
getIdeMode(): boolean {
|
getIdeMode(): boolean {
|
||||||
return this.ideMode;
|
return this.ideMode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue