MCPcopy Create free account
hub / github.com/diillson/chatcli / renderCoderPolicy

Method renderCoderPolicy

cli/config_sections.go:1492–1520  ·  view source on GitHub ↗

renderCoderPolicy prints coder policy state: active policy file, local override, merge mode, rule count, and the last pattern that matched in this session. Isolated from the main security section so a policy-manager init failure doesn't abort the whole block.

(p string)

Source from the content-addressed store, hash-verified

1490// this session. Isolated from the main security section so a policy-manager
1491// init failure doesn't abort the whole block.
1492func (cli *ChatCLI) renderCoderPolicy(p string) {
1493 policyPath := i18n.T("cfg.val.unknown")
1494 localPath := i18n.T("cfg.val.none")
1495 localMerge := i18n.T("cfg.val.off")
1496 rulesCount := "0"
1497 lastRule := i18n.T("cfg.val.no_matches_yet")
1498
1499 if pm, err := coder.NewPolicyManager(cli.logger); err == nil {
1500 policyPath = pm.ActivePolicyPath()
1501 if lp := pm.LocalPolicyPath(); strings.TrimSpace(lp) != "" {
1502 localPath = lp
1503 if pm.LocalMergeEnabled() {
1504 localMerge = i18n.T("cfg.val.on")
1505 }
1506 }
1507 rulesCount = fmt.Sprintf("%d", pm.RulesCount())
1508 }
1509 if cli.agentMode != nil && cli.agentMode.lastPolicyMatch != nil {
1510 lastRule = fmt.Sprintf("%s => %s",
1511 cli.agentMode.lastPolicyMatch.Pattern,
1512 cli.agentMode.lastPolicyMatch.Action)
1513 }
1514
1515 kv(p, i18n.T("cfg.kv.active_policy"), policyPath)
1516 kv(p, i18n.T("cfg.kv.local_override"), localPath)
1517 kv(p, i18n.T("cfg.kv.local_merge"), localMerge)
1518 kv(p, i18n.T("cfg.kv.rule_count"), rulesCount)
1519 kv(p, i18n.T("cfg.kv.last_match"), lastRule)
1520}

Callers 1

showConfigSecurityMethod · 0.95

Calls 7

ActivePolicyPathMethod · 0.95
LocalPolicyPathMethod · 0.95
LocalMergeEnabledMethod · 0.95
RulesCountMethod · 0.95
TFunction · 0.92
NewPolicyManagerFunction · 0.92
kvFunction · 0.70

Tested by

no test coverage detected