feat: add tool-specific approval overrides

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-24 20:02:29 +01:00
co-authored by Copilot
parent f896fa6442
commit d5c538eed9
22 changed files with 897 additions and 221 deletions
+29
View File
@@ -2,8 +2,10 @@ import { describe, expect, test } from 'bun:test';
import type { PatternDefinition } from '@shared/domain/pattern';
import {
applySessionApprovalSettings,
applyScratchpadSessionConfig,
createScratchpadSessionConfig,
resolveSessionApprovalSettings,
resolveSessionToolingSelection,
resolveSessionTitle,
resolveScratchpadSessionConfig,
@@ -143,3 +145,30 @@ describe('session tooling helpers', () => {
});
});
});
describe('session approval helpers', () => {
test('normalizes session approval overrides and applies them over pattern defaults', () => {
const pattern = {
...createPattern(),
approvalPolicy: {
rules: [{ kind: 'tool-call' as const }],
autoApprovedToolNames: ['git.status'],
},
};
expect(resolveSessionApprovalSettings(createSession())).toBeUndefined();
expect(
applySessionApprovalSettings(
pattern,
createSession({
approvalSettings: {
autoApprovedToolNames: ['git.diff', ' git.diff '],
},
}),
).approvalPolicy,
).toEqual({
rules: [{ kind: 'tool-call' }],
autoApprovedToolNames: ['git.diff'],
});
});
});