diff --git a/packages/core/src/policy/config.test.ts b/packages/core/src/policy/config.test.ts index a9fae7a1fa..63feb3042e 100644 --- a/packages/core/src/policy/config.test.ts +++ b/packages/core/src/policy/config.test.ts @@ -1169,17 +1169,13 @@ modes = ["plan"] r.argsPattern, ); expect(shellRules).toHaveLength(2); - expect( - shellRules?.some((r) => r.argsPattern?.test('{"command":"git status"}')), - ).toBe(true); - expect( - shellRules?.some((r) => r.argsPattern?.test('{"command":"git diff"}')), - ).toBe(true); - expect( - shellRules?.every( - (r) => !r.argsPattern?.test('{"command":"git commit"}'), - ), - ).toBe(true); + expect(shellRules?.some((r) => r.argsPattern?.test('git status'))).toBe( + true, + ); + expect(shellRules?.some((r) => r.argsPattern?.test('git diff'))).toBe(true); + expect(shellRules?.every((r) => !r.argsPattern?.test('git commit'))).toBe( + true, + ); const subagentRule = config.rules?.find( (r) => diff --git a/packages/core/src/policy/persistence.test.ts b/packages/core/src/policy/persistence.test.ts index 43f52a956d..ae3990c6bd 100644 --- a/packages/core/src/policy/persistence.test.ts +++ b/packages/core/src/policy/persistence.test.ts @@ -154,8 +154,9 @@ describe('createPolicyUpdater', () => { expect(addedRule).toBeDefined(); expect(addedRule?.priority).toBe(ALWAYS_ALLOW_PRIORITY); expect(addedRule?.argsPattern).toEqual( - new RegExp(`"command":"git\\ status(?:[\\s"]|\\\\")`), + new RegExp(`^git\\ status(?:\\s|$)`), ); + expect(addedRule?.argName).toBe('command'); // Verify file written expect(fs.open).toHaveBeenCalledWith(expect.stringMatching(/\.tmp$/), 'wx'); diff --git a/packages/core/src/policy/policy-updater.test.ts b/packages/core/src/policy/policy-updater.test.ts index 40780a1850..2d22d334ad 100644 --- a/packages/core/src/policy/policy-updater.test.ts +++ b/packages/core/src/policy/policy-updater.test.ts @@ -75,7 +75,8 @@ describe('createPolicyUpdater', () => { expect.objectContaining({ toolName: 'run_shell_command', priority: ALWAYS_ALLOW_PRIORITY, - argsPattern: new RegExp('"command":"echo(?:[\\s"]|\\\\")'), + argsPattern: new RegExp('^echo(?:\\s|$)'), + argName: 'command', }), ); expect(policyEngine.addRule).toHaveBeenNthCalledWith( @@ -83,7 +84,8 @@ describe('createPolicyUpdater', () => { expect.objectContaining({ toolName: 'run_shell_command', priority: ALWAYS_ALLOW_PRIORITY, - argsPattern: new RegExp('"command":"ls(?:[\\s"]|\\\\")'), + argsPattern: new RegExp('^ls(?:\\s|$)'), + argName: 'command', }), ); }); @@ -103,7 +105,8 @@ describe('createPolicyUpdater', () => { expect.objectContaining({ toolName: 'run_shell_command', priority: ALWAYS_ALLOW_PRIORITY, - argsPattern: new RegExp('"command":"git(?:[\\s"]|\\\\")'), + argsPattern: new RegExp('^git(?:\\s|$)'), + argName: 'command', }), ); });