MCPcopy Create free account
hub / github.com/Noumena-Network/code / createMockContext

Function createMockContext

src/commands/commit.e2e.test.ts:11–59  ·  view source on GitHub ↗
(allowedTools: string[])

Source from the content-addressed store, hash-verified

9const BASE_TMP = '/tmp/ncode-commit-test'
10
11function 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
61async function assertAllowed(
62 command: string,

Callers 2

assertAllowedFunction · 0.70
assertDeniedFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected