#\!/usr/bin/env node
/**
* Attribution Handler
*
* A utility that detects and removes AI attribution from:
* - Commit messages
* - PR descriptions
* - Code files
*
* Works with the Git hooks system to enforce project attribution guidelines.
*/
// Standard attribution patterns
const ATTRIBUTION_PATTERNS = [
"🤖 Generated with [Claude Code]",
"Co-Authored-By: Claude",
"Generated with Claude",
"Generated by AI",
"AI-generated"
];
// Standard attribution block that appears at the end of commit messages
const STANDARD_BLOCK = `🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>`;
/**
* Remove attribution patterns from text
* @param {string} text - The text to clean
* @returns {string} - Cleaned text
*/
function removeAttribution(text) {
// First try to remove the standard block
if (text.includes(STANDARD_BLOCK)) {
console.log("Removed standard attribution block");
return text.replace(STANDARD_BLOCK, "");
}
// Then check for individual patterns
let modified = false;
let result = text;
for (const pattern of ATTRIBUTION_PATTERNS) {
if (result.includes(pattern)) {
console.log(`Removed attribution pattern: "${pattern}"`);
result = result.replace(new RegExp(pattern, 'g'), "");
modified = true;
}
}
return result;
}
module.exports = {
removeAttribution,
ATTRIBUTION_PATTERNS,
STANDARD_BLOCK
};