feat: Rule ID visibility, stable IDs, list_rules tool, and rules-picker CLI#36
Merged
Conversation
…picker CLI Implements the rule-discoverability and toggling work from issue #24. - Show each finding's rule ID in the hook's block message (e.g. "OpenAI API Key (openai-api-key): sk-p…3xyz"), plus a hint line pointing at disabledRules in .privacy-guard.json. - Make external rule IDs (data/regex_list_1.json) stable across data-file reordering: collisions are now disambiguated with a short hash of the entry's own content instead of a positional counter. - Add a list_rules MCP tool that returns id, title, severity, category, source, and disabled state for every rule, for use from inside a Claude Code chat session. - Add a companion CLI (bin: claude-code-privacy-guard, invoked as `npx claude-code-privacy-guard rules`) that starts a loopback-only local web UI listing every rule with checkboxes. Toggling a rule auto-saves (debounced) straight to disabledRules; the server stays alive across saves and only exits on Ctrl+C or 10 minutes of inactivity. The save endpoint is protected by a random per-run token as defense in depth. - Config resolution favors an existing project-level .privacy-guard.json, but falls back to a global ~/.privacy-guard.json by default when none exists anywhere in the directory tree, since Privacy Guard is meant to protect the person, not one repo. Both the console output and the web page label which scope (global vs. project-level override) is being edited. - Document all of the above in README.md, including the new "Managing Rules" section.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #24.
Summary
OpenAI API Key (openai-api-key): sk-p…3xyz) plus a hint pointing atdisabledRulesin.privacy-guard.json.data/regex_list_1.json) are now stable across data-file reordering - collisions are disambiguated with a short hash of the entry's own content instead of a positional counter.list_rulesMCP tool returns id/title/severity/category/source/disabled for every rule, for in-chat use.bin: claude-code-privacy-guard, run asnpx claude-code-privacy-guard rules) starts a loopback-only local web UI listing every rule with checkboxes. Toggling auto-saves (debounced) todisabledRules; the server stays alive across saves and only exits on Ctrl+C or 10 minutes idle. The save endpoint requires a random per-run token as defense in depth..privacy-guard.json, but falls back to a global~/.privacy-guard.jsonby default when none exists anywhere in the directory tree - Privacy Guard protects the person, not one repo. Both the console output and the web page label which scope is being edited.Test plan
npm run build- cleannpm test- 159/159 passingeslint src --ext .ts- cleanlist_rulesMCP tool over real stdio, CLI save endpoint (bad token → 403/no write, good token → 200/write, preserves other config keys), server survives repeated saves without closing, auto-save on checkbox toggle with debounce/coalescing, config resolution correctly falls back to a fake$HOMEwhen no project config exists and prefers an existing project-level config when one doesNot included
npm publish) sonpx claude-code-privacy-guard rulesresolves for real users - this is a separate action I want explicit sign-off on before running, since it's a new public distribution channel.