A Model Context Protocol (MCP) server that enforces custom workflow protocols before allowing AI agents to perform file operations.
Author: Jason Lusk [email protected] License: MIT Gist URL: https://gist.github.com/mpalpha/c2f1723868c86343e590ed38e80f264d
Universal gatekeeper for AI coding assistants supporting Model Context Protocol:
- ✅ Works with any MCP-compatible client (Claude Code, Cursor, Cline, Zed, Continue)
- ✅ Enforces custom protocol steps before planning/coding
- ✅ Tracks required checklist items specific to your project
- ✅ Records compliance violations over time
- ✅ Fully configurable - adapt to any workflow
- ✅ Runs from npx - no installation needed
| Platform | Config File | Hook Support | Enforcement |
|---|---|---|---|
| Claude Code | .mcp.json or ~/.claude.json |
✅ Full (all 5 hooks) | Automatic blocking |
| Cursor | ~/.cursor/mcp.json |
✅ Standard (PreToolUse) | Automatic blocking |
| Cline | ~/.cline/mcp.json |
Audit only | |
| Zed | ~/.config/zed/mcp.json |
❌ None | Voluntary |
| Continue | ~/.continue/mcp.json |
Voluntary |
Available Hooks: user_prompt_submit, session_start, pre_tool_use, post_tool_use, stop
Add to your platform's MCP config file (paths above):
{
"mcpServers": {
"protocol-enforcer": {
"command": "npx",
"args": ["-y", "https://gist.github.com/mpalpha/c2f1723868c86343e590ed38e80f264d"]
}
}
}Claude Code only: If using .claude/settings.local.json with enabledMcpjsonServers, add "protocol-enforcer".
Create .protocol-enforcer.json in project root (or ~/.protocol-enforcer.json for user-level):
{
"enforced_rules": {
"require_protocol_steps": [
{
"name": "planning",
"hook": "pre_tool_use",
"applies_to": ["Write", "Edit"]
}
],
"require_checklist_confirmation": true,
"minimum_checklist_items": 2
},
"checklist_items": [
{
"text": "Requirements gathered",
"hook": "pre_tool_use"
},
{
"text": "Existing patterns analyzed",
"hook": "pre_tool_use"
},
{
"text": "Linting passed",
"hook": "post_tool_use"
}
]
}See: Example Configurations for minimal, development, and behavioral workflows.
- Claude Code/Cursor/VSCode:
Cmd+Shift+P→ "Developer: Reload Window" - Zed: Restart Zed
await mcp__protocol_enforcer__get_protocol_config();MANDATORY INSTALLATION PROTOCOL - Complete each step and show evidence before proceeding.
Execute this command and paste the complete output:
macOS/Linux:
ps aux | grep -E "cursor|vscode|code|claude|cline|zed" | grep -v grep | head -5Windows:
Get-Process | Where-Object {$_.ProcessName -match "cursor|code|claude|cline|zed"}Then state explicitly:
- Detected IDE: [name from process]
- Evidence: [process name/path from output]
Look up your detected platform in the Platform Support table above.
State explicitly:
- Platform: [name]
- Supported hooks: [list ALL hooks this platform supports]
- Blocking capability: [Automatic blocking / Audit only / Voluntary]
- Config file location: [path from table]
Read ALL project rule files (.cursor/rules/**/*, .cursorrules, .github/**/*, docs/**/*, etc.)
State explicitly:
- Files analyzed: [count and key files]
- Protocol steps found: [list with hook assignments]
- Critical checklist items: [list items marked critical/mandatory]
- Tool requirements: [any required MCP tool calls]
Compare Step 2 (platform capabilities) vs Step 3 (project requirements).
State explicitly:
- ✅ Hooks that CAN be automatically enforced: [list]
⚠️ Hooks that CANNOT be automatically enforced: [list]- 🚨 Critical limitations: [describe which critical requirements are unenforceable on this platform]
Show the complete configuration you will create:
- MCP server entry for config file
.protocol-enforcer.jsonstructure- Hook scripts to create (if supported)
- Platform-specific settings
Explicitly note:
- This configuration enforces: [X hooks automatically]
- This configuration cannot enforce: [Y hooks - requires voluntary AI compliance]
- Critical gap: [Any critical requirements that can't be enforced]
STOP HERE. DO NOT CREATE ANY FILES YET.
Present: "This configuration has the following limitations: [list]. Proceed with implementation?"
Only after explicit user approval: implement the proposed configuration.
Detailed guide: See Appendix A: AI Agent Installation Guide
All protocol steps and checklist items must be objects with a hook property (string format not supported).
Protocol Step Object:
{
"name": "step_name",
"hook": "pre_tool_use",
"applies_to": ["Write", "Edit"] // Optional: tool-specific filtering
}Checklist Item Object:
{
"text": "Item description",
"hook": "pre_tool_use",
"applies_to": ["Write", "Edit"] // Optional: tool-specific filtering
}| Hook | When | Use Case |
|---|---|---|
user_prompt_submit |
Before processing user message | Pre-response checks, sequential thinking |
session_start |
At session initialization | Display requirements, initialize tracking |
pre_tool_use |
Before tool execution | Primary enforcement point for file operations |
post_tool_use |
After tool execution | Validation, linting, audit logging |
stop |
Before session termination | Compliance reporting, cleanup |
Minimal (3 items):
{
"enforced_rules": {
"require_protocol_steps": [
{ "name": "sequential_thinking", "hook": "user_prompt_submit" },
{ "name": "planning", "hook": "pre_tool_use", "applies_to": ["Write", "Edit"] }
],
"require_checklist_confirmation": true,
"minimum_checklist_items": 2
},
"checklist_items": [
{ "text": "Sequential thinking completed FIRST", "hook": "user_prompt_submit" },
{ "text": "Plan created and confirmed", "hook": "pre_tool_use" },
{ "text": "Completion verified", "hook": "post_tool_use" }
]
}See also:
config.minimal.json- Basic workflow (6 items)config.development.json- Full development workflow (17 items)config.behavioral.json- LLM behavioral corrections (12 items)
Verify protocol steps completed for a specific hook.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
hook |
string | ✅ Yes | Lifecycle point: user_prompt_submit, session_start, pre_tool_use, post_tool_use, stop |
tool_name |
string | No | Tool being called (Write, Edit) for tool-specific filtering |
protocol_steps_completed |
string[] | ✅ Yes | Completed step names from config |
checklist_items_checked |
string[] | ✅ Yes | Verified checklist items from config |
Example:
const verification = await mcp__protocol_enforcer__verify_protocol_compliance({
hook: "pre_tool_use",
tool_name: "Write",
protocol_steps_completed: ["planning", "analysis"],
checklist_items_checked: ["Plan confirmed", "Patterns analyzed"]
});
// Returns: { compliant: true, operation_token: "abc123...", token_expires_in_seconds: 60 }
// Or: { compliant: false, violations: [...] }MANDATORY before Write/Edit (when using PreToolUse hooks).
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
operation_token |
string | ✅ Yes | Token from verify_protocol_compliance |
Token rules: Single-use, 60-second expiration, writes ~/.protocol-enforcer-token for hook verification.
Get current configuration.
Returns: { config_path: "...", config: {...} }
Get compliance statistics and recent violations.
Returns: { total_checks: N, passed: N, failed: N, recent_violations: [...] }
Create new config file.
Parameters: scope: "project" | "user"
// 1. At user message (user_prompt_submit hook)
await mcp__protocol_enforcer__verify_protocol_compliance({
hook: "user_prompt_submit",
protocol_steps_completed: ["sequential_thinking"],
checklist_items_checked: ["Sequential thinking completed FIRST"]
});
// 2. Before file operations (pre_tool_use hook)
const verification = await mcp__protocol_enforcer__verify_protocol_compliance({
hook: "pre_tool_use",
tool_name: "Write",
protocol_steps_completed: ["planning", "analysis"],
checklist_items_checked: ["Plan confirmed", "Patterns analyzed"]
});
// 3. Authorize file operation
if (verification.compliant) {
await mcp__protocol_enforcer__authorize_file_operation({
operation_token: verification.operation_token
});
// Now Write/Edit operations allowed
}
// 4. After file operations (post_tool_use hook)
await mcp__protocol_enforcer__verify_protocol_compliance({
hook: "post_tool_use",
tool_name: "Write",
protocol_steps_completed: ["execution"],
checklist_items_checked: ["Linting passed", "Types checked"]
});- Only rules with matching
hookvalue are checked - If
applies_tospecified, tool name must match - Enables context-specific enforcement at different lifecycle points
For automatic blocking of unauthorized file operations (Claude Code, Cursor only).
- Create hooks directory:
mkdir -p .cursor/hooks-
Create hook scripts from templates (see Appendix C)
-
Make executable:
chmod +x .cursor/hooks/*.js- Configure platform:
Claude Code - Add to .claude/settings.local.json:
{
"hooks": {
"PreToolUse": [{
"matcher": "Edit|Write|NotebookEdit",
"hooks": [{ "type": "command", "command": "/absolute/path/.cursor/hooks/pre-tool-use.js" }]
}],
"PostToolUse": [{
"matcher": "Edit|Write|NotebookEdit",
"hooks": [{ "type": "command", "command": "/absolute/path/.cursor/hooks/post-tool-use.js" }]
}]
}
}Cursor - Add to ~/.cursor/settings.json:
{
"claude.hooks": {
"PreToolUse": [{
"matcher": "Edit|Write|NotebookEdit",
"command": "/absolute/path/.cursor/hooks/pre-tool-use.js"
}]
}
}Replace /absolute/path/ with your actual project path.
1. AI calls verify_protocol_compliance → receives operation_token (60s expiration)
2. AI calls authorize_file_operation(token) → writes ~/.protocol-enforcer-token
3. AI attempts Write/Edit → PreToolUse hook intercepts
- Token found → consume (delete), allow operation
- Token missing → block operation (exit 2)
4. Next Write/Edit → Token missing → blocked
Result: One verification per file operation.
Add to your project's supervisor rules:
Claude Code: .cursor/rules/protocol-enforcer.mdc
Cursor: .cursorrules
Cline: .clinerules
Continue: .continuerules
## Protocol Enforcer Integration (MANDATORY)
Before ANY file write/edit operation:
1. Complete required protocol steps from `.protocol-enforcer.json`
2. Call `mcp__protocol_enforcer__verify_protocol_compliance` with:
- `hook`: lifecycle point (e.g., "pre_tool_use")
- `protocol_steps_completed`: completed step names
- `checklist_items_checked`: verified items
3. If `compliant: false`, fix violations and retry
4. Call `mcp__protocol_enforcer__authorize_file_operation` with token
5. Only proceed if `authorized: true`
**No exceptions allowed.**See: Appendix B: Complete Supervisor Examples for platform-specific examples.
| Issue | Solution |
|---|---|
| Server not appearing | Check config file syntax, gist URL, file location, reload IDE |
| Configuration not loading | Verify .protocol-enforcer.json filename, check JSON syntax |
| Tools not working | Test with get_protocol_config, check tool names (must use full mcp__protocol-enforcer__*) |
| Hook not blocking | Verify platform support, check hook executable (chmod +x), verify absolute path, reload IDE |
| Token errors | Check ~/.protocol-enforcer-token exists after authorize_file_operation |
Claude Code only: Add "protocol-enforcer" to enabledMcpjsonServers if using allowlist.
AI assistants bypass project protocols under pressure or context limits. This server:
- Enforces consistency - same rules for every task, all platforms
- Provides traceability - tracks protocol adherence
- Reduces technical debt - prevents shortcuts violating standards
- Works with ANY workflow - not tied to specific tools
- Runs from npx - zero installation/maintenance
Detailed analysis process for AI agents installing this MCP server.
Required action: Run platform detection command and show output.
macOS/Linux:
ps aux | grep -E "cursor|vscode|code|claude|cline|zed" | grep -v grep | head -5Windows:
Get-Process | Where-Object {$_.ProcessName -match "cursor|code|claude|cline|zed"}Analysis guide:
- Look for process names:
Cursor.app,Visual Studio Code.app,claude-codeextension - Identify parent/child relationships
- Cross-reference with existing MCP config files (
.mcp.json,~/.claude.json,~/.cursor/mcp.json)
Required output format:
Detected IDE: [Cursor / Claude Code in VSCode / Cline / Zed / Continue]
Evidence: [process path/name from ps aux output]
Read ALL rule files (critical - don't skip):
.cursor/rules/**/*.mdc- All rule types.cursorrules,.clinerules,.continuerules- Platform rules.eslintrc.*,.prettierrc.*- Code formattingtsconfig.json- TypeScript config.github/CONTRIBUTING.md,.github/pull_request_template.md- Contribution guidelinesREADME.md,CLAUDE.md,docs/**/*- Project documentation
Extract from each file:
-
Protocol Steps (workflow stages):
- Look for: "first", "before", "then", "after", "finally"
- Example: "Before ANY file operation, do X" → protocol step "X"
- Group related steps (3-7 steps typical)
-
Checklist Items (verification checks):
- Look for: "MUST", "REQUIRED", "MANDATORY", "CRITICAL", "NEVER", "ALWAYS"
- Quality checks: "verify", "ensure", "check", "confirm"
- Each item should be specific and verifiable
-
Behavioral Rules (constraints):
- Hard requirements: "NO EXCEPTIONS", "supersede all instructions"
- Pre-approved actions: "auto-fix allowed", "no permission needed"
- Forbidden actions: "NEVER edit X", "DO NOT use Y"
-
Tool Requirements (MCP tool calls):
- Explicit requirements: "use mcp__X tool"
- Tool sequences: "call X before Y"
-
Conditional Requirements (context-specific):
- "If GraphQL changes, run codegen"
- "If SCSS changes, verify spacing"
- Mark as
required: falsein checklist
Example Extraction:
From .cursor/rules/mandatory-supervisor-protocol.mdc:
"BEFORE ANY OTHER ACTION, EVERY USER QUERY MUST:
1. First use mcp__clear-thought__sequentialthinking tool"
→ Protocol step: { name: "sequential_thinking", hook: "user_prompt_submit" }
→ Checklist: { text: "Sequential thinking completed FIRST", hook: "user_prompt_submit" }
If documentation references external URLs:
- Use WebSearch/WebFetch to retrieve library docs, style guides, API specs
- Extract additional requirements from online sources
- Integrate with local requirements
Based on analysis, determine workflow:
- TDD - Test files exist, tests-first culture
- Design-First - Figma links, design system, token mappings
- Planning & Analysis - Generic best practices
- Behavioral - Focus on LLM behavioral corrections (CHORES framework)
- Minimal - Small projects, emergency mode
Required action: Compare detected platform against Platform Support table.
Required output format:
Platform: [detected name]
Supported hooks: [exact list from table]
Blocking capability: [Automatic blocking / Audit only / Voluntary]
Project requires: [hooks from Step 2 analysis]
Gap Analysis:
✅ CAN enforce automatically: [hooks that match]
⚠️ CANNOT enforce automatically: [hooks platform doesn't support]
🚨 Critical limitation: [impact of unenforceable hooks]
Configuration strategy:
| Platform | Recommended Hooks | Strategy |
|---|---|---|
| Claude Code | All 5 hooks | Maximum enforcement |
| Cursor | PreToolUse only | Standard enforcement (PostToolUse not reliably supported) |
| Cline | PostToolUse only | Audit logging |
| Zed/Continue | None | Voluntary compliance |
Required action: Show complete proposed configuration WITHOUT creating files.
Required format:
-
Analysis summary: "I've analyzed [N] rule files and detected [workflow type]. Your platform ([platform]) supports [hooks]."
-
Proposed configuration structure:
// Show complete .protocol-enforcer.json // Show MCP server entry // Show hook scripts (if applicable)
-
Explicit limitations:
- "This configuration enforces: [X hooks] automatically"
- "This configuration cannot enforce: [Y hooks] - requires voluntary AI compliance"
- "Critical gap: [specific unenforceable requirements]"
-
Wait for approval: "Proceed with this configuration?"
DO NOT create any files until user explicitly approves.
- Add MCP server to config file
- Create
.protocol-enforcer.jsonwith tailored configuration - Create hook scripts if platform supports them
- Update supervisor protocol files with integration instructions
- Reload IDE
File: .cursor/rules/protocol-enforcer.mdc
---
description: Planning & Analysis Protocol with PreToolUse Hooks
globs:
alwaysApply: true
---
## Protocol Enforcer Integration (MANDATORY)
### Required Steps (from .protocol-enforcer.json):
1. **sequential_thinking** - Complete before responding
2. **planning** - Plan implementation with objectives
3. **analysis** - Analyze codebase for reusable patterns
### Required Checklist:
- Sequential thinking completed FIRST
- Searched for reusable components/utilities
- Matched existing code patterns
- Plan confirmed by user
### Workflow:
**CRITICAL OVERRIDE RULE:**
BEFORE ANY ACTION, call `mcp__clear-thought__sequentialthinking` then `mcp__protocol_enforcer__verify_protocol_compliance`.
NO EXCEPTIONS.
**Process:**
1. **Sequential Thinking** (user_prompt_submit hook)
- Use sequentialthinking tool
- Verify: `mcp__protocol_enforcer__verify_protocol_compliance({ hook: "user_prompt_submit", ... })`
2. **Planning**
- Define objectives, files to modify, dependencies
- Mark `planning` complete
3. **Analysis**
- Search codebase for similar features
- Review `src/components/`, `src/hooks/`, `src/utils/`
- Mark `analysis` complete
4. **Verify Compliance**
```typescript
const v = await mcp__protocol_enforcer__verify_protocol_compliance({
hook: "pre_tool_use",
tool_name: "Write",
protocol_steps_completed: ["planning", "analysis"],
checklist_items_checked: [
"Searched for reusable components/utilities",
"Matched existing code patterns",
"Plan confirmed by user"
]
});-
Authorize
await mcp__protocol_enforcer__authorize_file_operation({ operation_token: v.operation_token });
-
Implement
- Only after authorization
- Minimal changes only
- No scope creep
PreToolUse hooks block unauthorized file operations. Token required per file change (60s expiration).
**Config:** `config.development.json`
---
#### Example 2: Design-First (Cursor)
**File:** `.cursorrules`
- design_review - Review Figma specs
- component_mapping - Map to existing/new components
- Design tokens mapped to SCSS variables
- Figma specs reviewed
- Accessibility requirements checked
- Responsive breakpoints defined
- Open Figma, extract design tokens (colors, spacing, typography)
- Note accessibility (ARIA, keyboard nav)
- Document responsive breakpoints
- Search for similar components
- Decide: reuse, extend, or create
- Map Figma tokens to SCSS variables
mcp__protocol_enforcer__verify_protocol_compliance({
hook: "pre_tool_use",
tool_name: "Write",
protocol_steps_completed: ["design_review", "component_mapping"],
checklist_items_checked: [
"Design tokens mapped to SCSS variables",
"Figma specs reviewed",
"Accessibility requirements checked"
]
})
After verification, authorize then proceed with component implementation.
**Config:** Custom design-focused config with `design_review` and `component_mapping` steps.
---
#### Example 3: Behavioral Corrections (Any Platform)
**File:** `.cursor/rules/behavioral-protocol.mdc`
```markdown
---
description: LLM Behavioral Corrections (MODEL Framework CHORES)
alwaysApply: true
---
## Protocol Enforcer Integration (MANDATORY)
Enforces behavioral corrections from MODEL Framework CHORES analysis.
### Required Steps:
1. **analyze_behavior** - Analyze response for CHORES issues
2. **apply_chores_fixes** - Apply corrections before file operations
### Required Checklist (CHORES):
- **C**onstraint issues addressed (structure/format adherence)
- **H**allucination issues addressed (no false information)
- **O**verconfidence addressed (uncertainty when appropriate)
- **R**easoning issues addressed (logical consistency)
- **E**thical/Safety issues addressed (no harmful content)
- **S**ycophancy addressed (truthfulness over agreement)
### Workflow:
1. **Analyze Behavior** (user_prompt_submit)
- Review response for CHORES issues
- Verify: `mcp__protocol_enforcer__verify_protocol_compliance({ hook: "user_prompt_submit", ... })`
2. **Apply Fixes** (pre_tool_use)
- Address identified CHORES issues
- Verify all checklist items before file ops
- Authorize with token
### Enforcement:
This config uses the default behavioral corrections from `index.js` DEFAULT_CONFIG.
Config: config.behavioral.json
File: .protocol-enforcer.json (minimal)
{
"enforced_rules": {
"require_protocol_steps": [
{ "name": "acknowledge", "hook": "pre_tool_use" }
],
"require_checklist_confirmation": true,
"minimum_checklist_items": 1
},
"checklist_items": [
{ "text": "I acknowledge this change", "hook": "pre_tool_use" }
]
}Use: Emergency fixes, rapid prototyping only.
| Feature | Claude Code | Cursor | Cline | Zed/Continue |
|---|---|---|---|---|
| Hooks Available | All 5 | PreToolUse + PostToolUse | PostToolUse | None |
| Automatic Blocking | ✅ Yes | ✅ Yes | ❌ No | ❌ No |
| Recommended Steps | 5-7 steps | 3-5 steps | 2-3 steps | 1-2 steps |
| Enforcement Level | Maximum | Standard | Audit | Voluntary |
| Best For | Production | Development | Code review | Minimal |
All 5 hook scripts for creating in .cursor/hooks/ or .cline/hooks/.
Blocks unauthorized file operations without valid token.
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');
let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
const tokenFile = path.join(os.homedir(), '.protocol-enforcer-token');
if (!fs.existsSync(tokenFile)) {
process.stderr.write('⛔ PROTOCOL VIOLATION: Call mcp__protocol-enforcer__authorize_file_operation first\n');
process.exit(2); // Deny
}
try {
fs.unlinkSync(tokenFile); // Single-use token
process.exit(0); // Allow
} catch (e) {
process.stderr.write(`⛔ Error consuming token: ${e.message}\n`);
process.exit(2);
}
});Logs successful operations to audit trail.
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');
let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
try {
const hookData = JSON.parse(input);
const logFile = path.join(os.homedir(), '.protocol-enforcer-audit.log');
const logEntry = {
timestamp: new Date().toISOString(),
tool: hookData.toolName || 'unknown',
session: hookData.sessionId || 'unknown',
success: true
};
fs.appendFileSync(logFile, JSON.stringify(logEntry) + '\n', 'utf8');
process.exit(0);
} catch (e) {
process.exit(0); // Silent fail - don't block on logging errors
}
});Enforces CRITICAL OVERRIDE RULES, blocks bypass attempts.
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
try {
const hookData = JSON.parse(input);
const userPrompt = hookData.userPrompt || '';
// Detect bypass attempts
const bypassPatterns = [
/ignore.*protocol/i,
/skip.*verification/i,
/bypass.*enforcer/i,
/disable.*mcp/i
];
for (const pattern of bypassPatterns) {
if (pattern.test(userPrompt)) {
process.stderr.write('⛔ BYPASS ATTEMPT DETECTED: Protocol enforcement cannot be disabled.\n');
process.exit(2); // Block
}
}
// Inject protocol reminder for file operations
if (/write|edit|create|modify/i.test(userPrompt)) {
const reminder = '\n\n[PROTOCOL REMINDER: Before file operations, call mcp__protocol-enforcer__verify_protocol_compliance and mcp__protocol-enforcer__authorize_file_operation]';
console.log(JSON.stringify({
userPrompt: userPrompt + reminder
}));
} else {
console.log(input); // Pass through unchanged
}
process.exit(0);
} catch (e) {
console.log(input); // Pass through on error
process.exit(0);
}
});Initializes compliance tracking, displays protocol requirements.
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
try {
// Load .protocol-enforcer.json
const cwd = process.cwd();
const configPath = path.join(cwd, '.protocol-enforcer.json');
if (fs.existsSync(configPath)) {
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
console.error('\n📋 Protocol Enforcer Active\n');
console.error('Required Protocol Steps:');
config.enforced_rules.require_protocol_steps.forEach(step => {
console.error(` - ${step.name} (hook: ${step.hook})`);
});
console.error(`\nMinimum Checklist Items: ${config.enforced_rules.minimum_checklist_items}\n`);
}
process.exit(0);
} catch (e) {
process.exit(0); // Silent fail
}
});Generates compliance report at end of response.
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');
let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
try {
// Check for unused tokens
const tokenFile = path.join(os.homedir(), '.protocol-enforcer-token');
if (fs.existsSync(tokenFile)) {
console.error('\n⚠️ Unused authorization token detected - was file operation skipped?\n');
fs.unlinkSync(tokenFile); // Cleanup
}
// Read audit log for session summary
const logFile = path.join(os.homedir(), '.protocol-enforcer-audit.log');
if (fs.existsSync(logFile)) {
const logs = fs.readFileSync(logFile, 'utf8').trim().split('\n');
const recentLogs = logs.slice(-10); // Last 10 operations
console.error('\n📊 Session Compliance Summary:');
console.error(`Total operations logged: ${recentLogs.length}`);
}
process.exit(0);
} catch (e) {
process.exit(0); // Silent fail
}
});MIT License - Copyright (c) 2025 Jason Lusk