(allowedTools: string[])
| 9 | const BASE_TMP = '/tmp/ncode-commit-test' |
| 10 | |
| 11 | function createMockContext(allowedTools: string[]) { |
| 12 | return { |
| 13 | abortController: new AbortController(), |
| 14 | readFileState: { get: () => undefined, set: () => {}, clear: () => {} }, |
| 15 | setAppState: () => {}, |
| 16 | setAppStateForTasks: () => {}, |
| 17 | getAppState: () => ({ |
| 18 | toolPermissionContext: { |
| 19 | mode: 'default' as const, |
| 20 | alwaysAllowRules: { |
| 21 | command: allowedTools, |
| 22 | }, |
| 23 | alwaysDenyRules: {}, |
| 24 | alwaysAskRules: {}, |
| 25 | sessionApprovedTools: new Set(), |
| 26 | explicitDenials: [], |
| 27 | trackDenial: () => {}, |
| 28 | sessionApprovedCommands: new Set(), |
| 29 | commandFingerprintToToolName: new Map(), |
| 30 | additionalWorkingDirectories: new Map(), |
| 31 | }, |
| 32 | messages: [], |
| 33 | replBridgeEnabled: false, |
| 34 | mainLoopModelForSession: null, |
| 35 | mainLoopModel: null, |
| 36 | denialTracking: { |
| 37 | consecutiveDenials: 0, |
| 38 | totalDenials: 0, |
| 39 | lastDeniedAt: null, |
| 40 | classifierConsecutiveDenials: 0, |
| 41 | classifierTotalDenials: 0, |
| 42 | }, |
| 43 | }), |
| 44 | options: { |
| 45 | commands: [], |
| 46 | debug: false, |
| 47 | mainLoopModel: 'test', |
| 48 | tools: [], |
| 49 | verbose: false, |
| 50 | thinkingConfig: { enabled: false }, |
| 51 | mcpClients: [], |
| 52 | mcpResources: {}, |
| 53 | isNonInteractiveSession: false, |
| 54 | agentDefinitions: { agents: [], activeAgentType: null }, |
| 55 | }, |
| 56 | addNotification: () => {}, |
| 57 | localDenialTracking: undefined, |
| 58 | } as never |
| 59 | } |
| 60 | |
| 61 | async function assertAllowed( |
| 62 | command: string, |
no outgoing calls
no test coverage detected