From 1ec172e34be4db45ea42f35cd7f75ea9440e986f Mon Sep 17 00:00:00 2001 From: Allen Hutchison Date: Thu, 22 Jan 2026 16:36:44 -0800 Subject: [PATCH] fix(cli): include source in policy rule display (#17358) --- packages/cli/src/ui/commands/policiesCommand.test.ts | 4 +++- packages/cli/src/ui/commands/policiesCommand.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ui/commands/policiesCommand.test.ts b/packages/cli/src/ui/commands/policiesCommand.test.ts index edd83ed4a6..4f224201c9 100644 --- a/packages/cli/src/ui/commands/policiesCommand.test.ts +++ b/packages/cli/src/ui/commands/policiesCommand.test.ts @@ -109,7 +109,9 @@ describe('policiesCommand', () => { expect(content).toContain( '**DENY** tool: `dangerousTool` [Priority: 10]', ); - expect(content).toContain('**ALLOW** all tools (args match: `safe`)'); + expect(content).toContain( + '**ALLOW** all tools (args match: `safe`) [Source: test.toml]', + ); expect(content).toContain('**ASK_USER** all tools'); }); }); diff --git a/packages/cli/src/ui/commands/policiesCommand.ts b/packages/cli/src/ui/commands/policiesCommand.ts index 198d46be4a..ebfd57abaf 100644 --- a/packages/cli/src/ui/commands/policiesCommand.ts +++ b/packages/cli/src/ui/commands/policiesCommand.ts @@ -36,7 +36,8 @@ const categorizeRulesByMode = ( const formatRule = (rule: PolicyRule, i: number) => `${i + 1}. **${rule.decision.toUpperCase()}** ${rule.toolName ? `tool: \`${rule.toolName}\`` : 'all tools'}` + (rule.argsPattern ? ` (args match: \`${rule.argsPattern.source}\`)` : '') + - (rule.priority !== undefined ? ` [Priority: ${rule.priority}]` : ''); + (rule.priority !== undefined ? ` [Priority: ${rule.priority}]` : '') + + (rule.source ? ` [Source: ${rule.source}]` : ''); const formatSection = (title: string, rules: PolicyRule[]) => `### ${title}\n${rules.length ? rules.map(formatRule).join('\n') : '_No policies._'}\n\n`;