From a3234fb534f71f2561083118b0979a2788416f3d Mon Sep 17 00:00:00 2001
From: Abhi <43648792+abhipatel12@users.noreply.github.com>
Date: Wed, 14 Jan 2026 13:50:28 -0500
Subject: [PATCH] prefactor: add rootCommands as array so it can be used for
policy parsing (#16640)
---
packages/cli/src/ui/components/HistoryItemDisplay.test.tsx | 1 +
.../src/ui/components/messages/ToolConfirmationMessage.test.tsx | 1 +
packages/cli/src/ui/utils/textUtils.test.ts | 1 +
packages/core/src/core/coreToolScheduler.test.ts | 1 +
packages/core/src/test-utils/mock-tool.ts | 1 +
packages/core/src/tools/shell.ts | 1 +
packages/core/src/tools/tools.ts | 1 +
7 files changed, 7 insertions(+)
diff --git a/packages/cli/src/ui/components/HistoryItemDisplay.test.tsx b/packages/cli/src/ui/components/HistoryItemDisplay.test.tsx
index 17fd06e6c8..1aecb9a0ba 100644
--- a/packages/cli/src/ui/components/HistoryItemDisplay.test.tsx
+++ b/packages/cli/src/ui/components/HistoryItemDisplay.test.tsx
@@ -208,6 +208,7 @@ describe('', () => {
title: 'Run Shell Command',
command: 'echo "\u001b[31mhello\u001b[0m"',
rootCommand: 'echo',
+ rootCommands: ['echo'],
onConfirm: async () => {},
},
},
diff --git a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx
index 0291396e63..7444f4f2ec 100644
--- a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx
+++ b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx
@@ -83,6 +83,7 @@ describe('ToolConfirmationMessage', () => {
title: 'Confirm Execution',
command: 'echo "hello"',
rootCommand: 'echo',
+ rootCommands: ['echo'],
onConfirm: vi.fn(),
};
diff --git a/packages/cli/src/ui/utils/textUtils.test.ts b/packages/cli/src/ui/utils/textUtils.test.ts
index f9a90c63b4..e9bb0c196a 100644
--- a/packages/cli/src/ui/utils/textUtils.test.ts
+++ b/packages/cli/src/ui/utils/textUtils.test.ts
@@ -63,6 +63,7 @@ describe('textUtils', () => {
type: 'exec',
command: '\u001b[31mmls -l\u001b[0m',
rootCommand: '\u001b[32msudo apt-get update\u001b[0m',
+ rootCommands: ['sudo'],
onConfirm: async () => {},
};
diff --git a/packages/core/src/core/coreToolScheduler.test.ts b/packages/core/src/core/coreToolScheduler.test.ts
index c27e194cc6..90b8ea7938 100644
--- a/packages/core/src/core/coreToolScheduler.test.ts
+++ b/packages/core/src/core/coreToolScheduler.test.ts
@@ -1245,6 +1245,7 @@ describe('CoreToolScheduler request queueing', () => {
title: 'Confirm Shell Command',
command: String(params['command'] ?? ''),
rootCommand: 'git',
+ rootCommands: ['git'],
onConfirm: async () => {},
}),
execute: () => executeFn({}),
diff --git a/packages/core/src/test-utils/mock-tool.ts b/packages/core/src/test-utils/mock-tool.ts
index 2c12aa0962..4fa536d2db 100644
--- a/packages/core/src/test-utils/mock-tool.ts
+++ b/packages/core/src/test-utils/mock-tool.ts
@@ -136,6 +136,7 @@ export const MOCK_TOOL_SHOULD_CONFIRM_EXECUTE = () =>
title: 'Confirm mockTool',
command: 'mockTool',
rootCommand: 'mockTool',
+ rootCommands: ['mockTool'],
onConfirm: async () => {},
});
diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts
index a2d3b611c5..4fc8a64735 100644
--- a/packages/core/src/tools/shell.ts
+++ b/packages/core/src/tools/shell.ts
@@ -120,6 +120,7 @@ export class ShellToolInvocation extends BaseToolInvocation<
title: 'Confirm Shell Command',
command: this.params.command,
rootCommand: rootCommands.join(', '),
+ rootCommands,
onConfirm: async (outcome: ToolConfirmationOutcome) => {
await this.publishPolicyUpdate(outcome);
},
diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts
index d3efd56ec1..1b365bde40 100644
--- a/packages/core/src/tools/tools.ts
+++ b/packages/core/src/tools/tools.ts
@@ -693,6 +693,7 @@ export interface ToolExecuteConfirmationDetails {
onConfirm: (outcome: ToolConfirmationOutcome) => Promise;
command: string;
rootCommand: string;
+ rootCommands: string[];
}
export interface ToolMcpConfirmationDetails {