Default-enable.

This commit is contained in:
Christian Gunderman
2026-04-13 10:50:08 -07:00
parent 05cdf19123
commit ab33a96d7c
5 changed files with 94 additions and 2 deletions
+61
View File
@@ -0,0 +1,61 @@
import { evaluate } from 'mathjs';
export interface CalculatorState {
display: string;
equation: string;
lastResult: string | null;
}
export const initialState: CalculatorState = {
display: '0',
equation: '',
lastResult: null,
};
export function handleInput(state: CalculatorState, input: string): CalculatorState {
if (/[0-9]/.test(input)) {
if (state.display === '0' || state.lastResult !== null) {
return { ...state, display: input, lastResult: null };
} else {
return { ...state, display: state.display + input };
}
} else if (input === '.') {
if (!state.display.includes('.')) {
return { ...state, display: state.display + '.' };
}
} else if (['+', '-', '*', '/'].includes(input)) {
return {
...state,
equation: `${state.display} ${input} `,
display: '0',
};
}
return state;
}
export function calculate(state: CalculatorState): CalculatorState {
try {
const fullEquation = state.equation + state.display;
const result = evaluate(fullEquation);
const resultStr = result.toString();
return {
display: resultStr,
equation: '',
lastResult: resultStr,
};
} catch (error) {
return {
display: 'Error',
equation: '',
lastResult: null,
};
}
}
export function deleteLast(state: CalculatorState): CalculatorState {
if (state.display.length > 1) {
return { ...state, display: state.display.slice(0, -1) };
} else {
return { ...state, display: '0' };
}
}
+26
View File
@@ -1867,6 +1867,32 @@ describe('loadCliConfig with admin.mcp.config', () => {
});
});
describe('loadCliConfig deepValidation', () => {
beforeEach(() => {
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
});
it('should enable deepValidation by default', async () => {
process.argv = ['node', 'script.js'];
const argv = await parseArguments(createTestMergedSettings());
const settings = createTestMergedSettings();
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.isDeepValidationEnabled()).toBe(true);
});
it('should allow disabling deepValidation via settings', async () => {
process.argv = ['node', 'script.js'];
const argv = await parseArguments(createTestMergedSettings());
const settings = createTestMergedSettings({
general: {
deepValidation: false,
},
});
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.isDeepValidationEnabled()).toBe(false);
});
});
describe('loadCliConfig model selection', () => {
beforeEach(() => {
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
+1 -1
View File
@@ -900,7 +900,7 @@ export async function loadCliConfig(
memoryBoundaryMarkers: settings.context?.memoryBoundaryMarkers,
importFormat: settings.context?.importFormat,
debugMode,
deepValidation: settings.general?.deepValidation,
deepValidation: settings.general?.deepValidation ?? true,
question,
worktreeSettings,
+1 -1
View File
@@ -241,7 +241,7 @@ const SETTINGS_SCHEMA = {
label: 'Deep Validation',
category: 'General',
requiresRestart: false,
default: false,
default: true,
description:
'Run a subagent after the main agent finishes to perform final validation.',
showInDialog: true,
+5
View File
@@ -2051,6 +2051,11 @@ export class Config implements McpContext, AgentLoopContext {
getDebugMode(): boolean {
return this.debugMode;
}
isDeepValidationEnabled(): boolean {
return this.deepValidation;
}
getQuestion(): string | undefined {
return this.question;
}