ai-naming-standard-mcp
Version:
AI Governance Era v6.1: loungeservice-grade project initialization. Creates 8-folder structure with complete AI governance (AI_RULES.md, AI_ROLE_MATRIX.yaml, NAMING_EXCEPTIONS.md, DEVELOPMENT.md, project.md) and bridge files (.cursorrules, .windsurfrules)
400 lines (368 loc) β’ 10.4 kB
JavaScript
// ========== π v6.0.0 New Tools ==========
// Multi-AI Orchestration, Naming Wizard, Dependency Graph, Governance
import { getMessages } from '../messages/index.js';
// ==========================================
// Multi-AI Orchestration Tools
// ==========================================
/**
* Create AI_ROLE_MATRIX.yaml for multi-AI collaboration
*/
export async function createAIRoleMatrix({ projectName = 'my-project', aiTools = ['cursor', 'claude', 'chatgpt'] }) {
const template = `# v6.0 - AI μν λ§€ν νμ€
version: "6.0.0"
updated: "${new Date().toISOString().split('T')[0]}"
project_name: "${projectName}"
roles:
${aiTools.includes('cursor') ? ` - name: cursor
type: code_writer
permissions:
- write: 03_ACTIVE
- test: 04_TEST
responsibilities:
- "λΉμ¦λμ€ λ‘μ§ μμ±"
- "ν
μ€νΈ μ½λ μμ±"
` : ''}${aiTools.includes('claude') ? ` - name: claude
type: reviewer
permissions:
- review: 03_ACTIVE
- document: 00_DOCS
responsibilities:
- "μ½λ 리뷰"
- "λ¬Έμ μμ±"
` : ''}${aiTools.includes('chatgpt') ? ` - name: chatgpt
type: architect
permissions:
- structure: 00_DOCS
- rule: 07_META
responsibilities:
- "ꡬ쑰 μ€κ³"
- "λ€μ΄λ° κ·μΉ κ΄λ¦¬"
` : ''} - name: human
type: supervisor
permissions:
- override: all
`;
return {
content: template,
fileName: 'AI_ROLE_MATRIX.yaml',
path: '07_META/AI_ROLE_MATRIX.yaml',
description: 'AI role matrix for multi-AI collaboration',
aiTools
};
}
/**
* Get AI role and permissions
*/
export async function getAIRole({ aiName }) {
const roles = {
cursor: {
type: 'code_writer',
permissions: ['write: 03_ACTIVE', 'test: 04_TEST'],
canModify: ['03_ACTIVE', '04_TEST'],
cannotModify: ['01_CONFIG', '07_META'],
responsibilities: ['μ½λ μμ±', 'ν
μ€νΈ μμ±', 'λ²κ·Έ μμ ']
},
claude: {
type: 'reviewer',
permissions: ['review: 03_ACTIVE', 'document: 00_DOCS'],
canModify: ['00_DOCS'],
cannotModify: ['03_ACTIVE', '01_CONFIG'],
responsibilities: ['μ½λ 리뷰', 'λ¬Έμ μμ±', 'μν€ν
μ² κ²μ¦']
},
chatgpt: {
type: 'architect',
permissions: ['structure: 00_DOCS', 'rule: 07_META'],
canModify: ['00_DOCS', '07_META'],
cannotModify: ['03_ACTIVE', '01_CONFIG'],
responsibilities: ['ꡬ쑰 μ€κ³', 'νμΌλͺ
μμ±', 'μμ‘΄μ± κ΄λ¦¬']
},
windsurf: {
type: 'assistant',
permissions: ['read: all', 'write: 03_ACTIVE'],
canModify: ['03_ACTIVE'],
cannotModify: ['01_CONFIG', '07_META'],
responsibilities: ['μ½λ 리ν©ν λ§', 'μ±λ₯ μ΅μ ν']
},
human: {
type: 'supervisor',
permissions: ['override: all', 'approve: all'],
canModify: ['all'],
cannotModify: [],
responsibilities: ['μ΅μ’
μΉμΈ', '보μ μ€μ ', 'νλ‘μ νΈ λ°©ν₯']
}
};
const role = roles[aiName];
if (!role) {
return { error: `Unknown AI: ${aiName}`, availableAIs: Object.keys(roles) };
}
return {
aiName,
...role,
description: `${aiName} is a ${role.type} with ${role.permissions.length} permissions`
};
}
// ==========================================
// Naming Wizard Tools
// ==========================================
/**
* Convert natural language to file name
*/
export async function naturalLanguageToFileName({ naturalLanguage, language = 'ko' }) {
// κ°λ¨ν ν€μλ λ§€ν (μ€μ λ‘λ NAMING_WIZARD_RULES.yaml μ¬μ©)
const rules = {
ko: {
// λλ©μΈ
'λ‘κ·ΈμΈ': 'User-Login',
'νμκ°μ
': 'User-Register',
'νλ‘ν': 'User-Profile',
'μν': 'Product',
'κ²μ': 'Search',
'κ²°μ ': 'Payment',
'μ£Όλ¬Έ': 'Order',
'μ·¨μ': 'Refund',
// μ‘μ
'λ§λ€': 'C',
'μμ±': 'C',
'μΆκ°': 'C',
'μ‘°ν': 'R',
'보기': 'R',
'μμ ': 'U',
'μμ ': 'D',
// λ μ΄μ΄
'νμ΄μ§': 'FE_Page',
'μ»΄ν¬λνΈ': 'FE_Component',
'μλΉμ€': 'BE_Service',
'API': 'BE_API',
'ν
μ΄λΈ': 'DB_Table'
}
};
const mapping = rules[language] || rules.ko;
const input = naturalLanguage.toLowerCase();
let domain = 'Unknown';
let action = 'R';
let layer = 'BE';
let detail = 'Service';
// λλ©μΈ κ°μ§
for (const [keyword, value] of Object.entries(mapping)) {
if (input.includes(keyword.toLowerCase())) {
if (value.includes('-')) domain = value;
else if (value.length === 1) action = value;
else if (value.includes('_')) {
const [l, d] = value.split('_');
layer = l;
detail = d;
}
}
}
const index = '001';
const env = 'PROD';
const ext = layer === 'FE' ? 'jsx' : layer === 'DB' ? 'sql' : 'py';
const fileName = `${index}_${layer}_${domain}_${action}_${detail}_${env}.${ext}`;
return {
input: naturalLanguage,
analysis: {
domain,
action,
layer,
detail,
env
},
fileName,
fullPath: `03_ACTIVE/${fileName}`,
confidence: domain !== 'Unknown' ? 'high' : 'low',
suggestion: domain === 'Unknown' ? 'Please provide more specific domain information' : null
};
}
/**
* Add custom naming wizard rule
*/
export async function addNamingWizardRule({ ruleType, keywords, output }) {
return {
ruleType,
keywords,
output,
status: 'Rule would be added to NAMING_WIZARD_RULES.yaml',
example: {
input: keywords[0],
output: output
}
};
}
// ==========================================
// Dependency Graph Tools
// ==========================================
/**
* Generate dependency graph from @deps tags
*/
export async function generateDepGraph({ sourcePath = '.', outputPath = '07_META/DEP_GRAPH.yaml' }) {
return {
status: 'would_scan',
sourcePath,
outputPath,
description: 'Would scan all files in 03_ACTIVE for @deps tags and generate DEP_GRAPH.yaml',
nextSteps: [
'1. Scan 03_ACTIVE folder',
'2. Extract @deps tags from files',
'3. Build dependency graph',
'4. Generate DEP_GRAPH.yaml',
'5. Check for circular dependencies'
],
exampleDeps: `/*
* @deps:
* - 002_BE_Order-Validate_V_Helper_PROD.py
* - 005_DB_Order-Schema_C_Migration_PROD.sql
*/`
};
}
/**
* Validate @deps tags in a file
*/
export async function validateDeps({ filePath }) {
return {
filePath,
status: 'would_validate',
checks: [
'Check if @deps tag exists',
'Verify all referenced files exist',
'Check for circular dependencies',
'Validate file path format'
],
expectedFormat: `/*
* @file: filename.ext
* @deps:
* - dependency1.ext
* - dependency2.ext
* @ai: cursor
* @reviewed: claude
*/`
};
}
/**
* Check for circular dependencies
*/
export async function checkCircularDeps({ depGraphPath = '07_META/DEP_GRAPH.yaml' }) {
return {
depGraphPath,
status: 'would_check',
description: 'Would analyze DEP_GRAPH.yaml for circular dependencies',
algorithm: 'Depth-First Search (DFS) for cycle detection',
exampleCircular: [
'A depends on B',
'B depends on C',
'C depends on A β οΈ CIRCULAR!'
]
};
}
// ==========================================
// Governance & Audit Tools
// ==========================================
/**
* Log human intervention
*/
export async function logHumanOverride({ fileName, reason, aiSuggestion = '', humanDecision, result = '' }) {
const timestamp = new Date().toISOString();
const logEntry = `
### Override #${Date.now()}
**Time**: ${new Date().toLocaleString()}
**File**: ${fileName}
**Reason**: ${reason}
${aiSuggestion ? `**AI Suggestion**: ${aiSuggestion} \n` : ''}**Human Decision**: ${humanDecision}
${result ? `**Result**: ${result} \n` : ''}
`;
return {
logEntry,
fileName: 'HUMAN_OVERRIDES.md',
path: '07_META/HUMAN_OVERRIDES.md',
timestamp,
description: 'Human intervention logged for audit trail'
};
}
// ==========================================
// Utility Tools
// ==========================================
/**
* Scan project structure
*/
export async function scanProject({ projectPath = '.', reportType = 'full' }) {
const reports = {
full: ['Structure', 'Dependencies', 'Compliance', 'Statistics'],
structure: ['Folder Structure', 'File Count', 'File Types'],
dependencies: ['Dependency Graph', 'Circular Dependencies', 'Orphan Files'],
compliance: ['Naming Convention', 'Folder Permissions', 'Missing @deps']
};
return {
projectPath,
reportType,
sections: reports[reportType],
status: 'would_scan',
description: `Would generate ${reportType} report for project at ${projectPath}`,
outputFormat: 'JSON + Markdown'
};
}
/**
* Export configuration for different AI tools
*/
export async function exportConfig({ targetTool, outputPath }) {
const configs = {
mcp: {
format: 'JSON',
file: 'ai-naming-standard.json',
content: {
mcpServers: {
'ai-naming-standard': {
command: 'node',
args: ['path/to/src/index.js']
}
}
}
},
cursor: {
format: 'JSON',
file: '.cursorrules',
content: {
rules: ['Use v6 naming convention', 'Check 07_META/AI_ROLE_MATRIX.yaml']
}
},
claude: {
format: 'Markdown',
file: 'CLAUDE_INSTRUCTIONS.md',
content: '# Claude Configuration\n\nUse v6 AI Naming Convention...'
},
vscode: {
format: 'JSON',
file: '.vscode/settings.json',
content: {
'files.exclude': {
'05_BUILD': true,
'06_LOGS': true
}
}
}
};
const config = configs[targetTool];
if (!config) {
return {
error: `Unknown target tool: ${targetTool}`,
availableTools: Object.keys(configs)
};
}
return {
targetTool,
...config,
outputPath: outputPath || config.file,
description: `Would export ${config.format} configuration for ${targetTool}`
};
}
// Export all v6 tools
export {
createAIRoleMatrix,
getAIRole,
naturalLanguageToFileName,
addNamingWizardRule,
generateDepGraph,
validateDeps,
checkCircularDeps,
logHumanOverride,
scanProject,
exportConfig
};