fix(cli): include source in policy rule display (#17358)

This commit is contained in:
Allen Hutchison 2026-01-22 16:36:44 -08:00 committed by GitHub
parent 678c58634b
commit 1ec172e34b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -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');
});
});

View File

@ -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`;