UNPKG

test-raghav-global-rules

Version:

Global rules and workspace configuration for Windsurf IDE to ensure consistent code quality across all projects

206 lines (169 loc) • 7.09 kB
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); class WindSurfMemoryCreator { constructor() { this.memoriesDir = path.join(__dirname, '..', 'memories'); this.corpusName = 'c:/Users/dwishiva/Downloads/techlive'; } async createMemoriesForRole(role) { if (!role) { this.showUsage(); return; } console.log(`🧠 Creating WindSurf memories for ${role} role...`); const memories = this.loadRoleMemories(role); if (memories.length === 0) { console.log(`āŒ No memory files found for role: ${role}`); console.log(`šŸ“ Expected location: memories/roles/${role}/`); return; } console.log(`šŸ“š Found ${memories.length} memory file(s)`); // Generate the Cascade instruction this.generateCascadeInstruction(memories, role); console.log(`\nāœ… Memory creation instruction generated!`); console.log(`šŸ“‹ Copy and paste the instruction below to Cascade:`); console.log(`\n${'='.repeat(80)}`); this.printCascadeInstruction(memories, role); console.log(`${'='.repeat(80)}\n`); } loadRoleMemories(role) { const memories = []; // Always include core memories (essential for all roles) const coreDir = path.join(this.memoriesDir, 'core'); if (fs.existsSync(coreDir)) { memories.push(...this.readMemoriesFromDir(coreDir, 'core')); } // Always include compliance memories (healthcare-specific) const complianceDir = path.join(this.memoriesDir, 'compliance'); if (fs.existsSync(complianceDir)) { memories.push(...this.readMemoriesFromDir(complianceDir, 'compliance')); } // Include role-specific memories const roleDir = path.join(this.memoriesDir, 'roles', role); if (fs.existsSync(roleDir)) { memories.push(...this.readMemoriesFromDir(roleDir, role)); } // Include application memories (architectural context) const appsDir = path.join(this.memoriesDir, 'applications'); if (fs.existsSync(appsDir)) { memories.push(...this.readMemoriesFromDir(appsDir, 'applications')); } return memories; } readMemoriesFromDir(dir, category) { const memories = []; const files = fs.readdirSync(dir, { withFileTypes: true }); files.forEach(file => { if (file.isFile() && file.name.endsWith('.md')) { const filePath = path.join(dir, file.name); const content = fs.readFileSync(filePath, 'utf8'); memories.push({ id: `${category}_${file.name.replace('.md', '')}`, title: this.extractTitle(content), content: content, tags: this.generateTags(content, category), filePath: filePath, category: category }); } else if (file.isDirectory()) { // Handle subdirectories const subDir = path.join(dir, file.name); memories.push(...this.readMemoriesFromDir(subDir, `${category}_${file.name}`)); } }); return memories; } extractTitle(content) { const titleMatch = content.match(/^#\s+(.+)$/m); return titleMatch ? titleMatch[1] : 'Untitled Memory'; } generateTags(content, role) { const tags = [role, 'techlive']; const lowerContent = content.toLowerCase(); // Healthcare-specific tags if (lowerContent.includes('hipaa')) tags.push('hipaa'); if (lowerContent.includes('healthcare')) tags.push('healthcare'); if (lowerContent.includes('compliance')) tags.push('compliance'); if (lowerContent.includes('security')) tags.push('security'); // Technology tags if (lowerContent.includes('react')) tags.push('react'); if (lowerContent.includes('typescript')) tags.push('typescript'); if (lowerContent.includes('kubernetes')) tags.push('kubernetes'); if (lowerContent.includes('docker')) tags.push('docker'); if (lowerContent.includes('testing')) tags.push('testing'); if (lowerContent.includes('material-ui')) tags.push('material-ui'); if (lowerContent.includes('redux')) tags.push('redux'); if (lowerContent.includes('zustand')) tags.push('zustand'); if (lowerContent.includes('phi')) tags.push('phi'); if (lowerContent.includes('audit')) tags.push('audit-logging'); return [...new Set(tags)]; // Remove duplicates } generateCascadeInstruction(memories, role) { const instruction = { role: role, timestamp: new Date().toISOString(), totalMemories: memories.length, corpusName: this.corpusName, memories: memories.map(m => ({ id: m.id, title: m.title, tags: m.tags, filePath: m.filePath, contentLength: m.content.length, content: m.content })) }; // Save instruction to file for reference const instructionPath = path.join(this.memoriesDir, `${role}-memory-instruction.json`); fs.writeFileSync(instructionPath, JSON.stringify(instruction, null, 2)); console.log(`šŸ“„ Instruction saved to: ${instructionPath}`); } printCascadeInstruction(memories, role) { console.log(`Please create WindSurf memories for the ${role} role using the following files:`); console.log(`\nRole: ${role}`); console.log(`Corpus: ${this.corpusName}`); console.log(`Total memories to create: ${memories.length}\n`); memories.forEach((memory, index) => { console.log(`${index + 1}. Create memory:`); console.log(` Title: ${memory.title}`); console.log(` Tags: ${memory.tags.join(', ')}`); console.log(` Source: ${memory.filePath}`); console.log(` Content length: ${memory.content.length} characters`); console.log(` Content preview: ${memory.content.substring(0, 100)}...`); console.log(''); }); console.log(`\nTo create these memories, you can either:`); console.log(`1. Ask Cascade: "Create all memories for ${role} role from the files listed above"`); console.log(`2. Use the detailed instruction file: ${role}-memory-instruction.json`); console.log(`3. Create them one by one using the file paths provided`); } showUsage() { console.log(` 🧠 WindSurf Memory Creator for TechLive Healthcare Platform Usage: node create-windsurf-memories.js <role> Available roles: frontend - React/TypeScript development standards devops - Deployment pipeline and infrastructure qa - Testing strategy and compliance security - Security protocols and HIPAA compliance Example: node create-windsurf-memories.js frontend This will: 1. Load all relevant .md files for the specified role 2. Generate a comprehensive instruction for Cascade 3. Show you exactly what to ask Cascade to create the memories 4. Save a detailed instruction file for reference Memory sources: - memories/core/ (essential for all roles) - memories/compliance/ (healthcare-specific) - memories/roles/<role>/ (role-specific) - memories/applications/ (architectural context) `); } } // Main execution const role = process.argv[2]; const creator = new WindSurfMemoryCreator(); creator.createMemoriesForRole(role);