mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
- Reorganize v3/ into implementation/ subfolders: - planning/, architecture/, migration/, integration/ - security/, adrs/, research/, swarm-plans/ - Add 15-agent concurrent swarm implementation plans: - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x) - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies - Update .claude/settings.json with proper hooks format - Add bash aliases for claude --dangerously-skip-permissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
175 lines
5.5 KiB
JavaScript
175 lines
5.5 KiB
JavaScript
// copy-revised-templates.js - Copy the revised template files from repository
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
// Source directory for revised templates (repository root .claude/commands)
|
|
const REPO_TEMPLATES_DIR = path.join(__dirname, '../../../../.claude/commands');
|
|
|
|
/**
|
|
* Copy revised template files from repository to target project
|
|
*/
|
|
export async function copyRevisedTemplates(targetDir, options = {}) {
|
|
const results = {
|
|
success: true,
|
|
copiedFiles: [],
|
|
skippedFiles: [],
|
|
errors: []
|
|
};
|
|
|
|
const targetCommandsDir = path.join(targetDir, '.claude/commands');
|
|
|
|
try {
|
|
// Ensure target directory exists
|
|
await fs.promises.mkdir(targetCommandsDir, { recursive: true });
|
|
|
|
// Copy all template files recursively
|
|
await copyDirectoryRecursive(REPO_TEMPLATES_DIR, targetCommandsDir, options, results);
|
|
|
|
// Copy additional .claude files if they exist
|
|
const additionalFiles = [
|
|
{ source: '../config.json', target: '.claude/config.json' },
|
|
{ source: '../settings.json', target: '.claude/settings.json' }
|
|
];
|
|
|
|
for (const file of additionalFiles) {
|
|
const sourcePath = path.join(REPO_TEMPLATES_DIR, file.source);
|
|
const targetPath = path.join(targetDir, file.target);
|
|
|
|
if (fs.existsSync(sourcePath)) {
|
|
try {
|
|
const targetDirPath = path.dirname(targetPath);
|
|
await fs.promises.mkdir(targetDirPath, { recursive: true });
|
|
|
|
if (!fs.existsSync(targetPath) || options.force) {
|
|
await fs.promises.copyFile(sourcePath, targetPath);
|
|
results.copiedFiles.push(file.target);
|
|
if (!options.dryRun) {
|
|
console.log(` ✓ Copied ${file.target}`);
|
|
}
|
|
} else {
|
|
results.skippedFiles.push(file.target);
|
|
if (!options.dryRun) {
|
|
console.log(` ⏭️ Skipped ${file.target} (already exists)`);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
results.errors.push(`Failed to copy ${file.target}: ${err.message}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
results.success = results.errors.length === 0;
|
|
} catch (err) {
|
|
results.success = false;
|
|
results.errors.push(`Failed to copy revised templates: ${err.message}`);
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
/**
|
|
* Recursively copy directory contents
|
|
*/
|
|
async function copyDirectoryRecursive(sourceDir, targetDir, options, results) {
|
|
try {
|
|
const entries = await fs.promises.readdir(sourceDir, { withFileTypes: true });
|
|
|
|
for (const entry of entries) {
|
|
const sourcePath = path.join(sourceDir, entry.name);
|
|
const targetPath = path.join(targetDir, entry.name);
|
|
|
|
if (entry.isDirectory()) {
|
|
// Create directory and recurse
|
|
await fs.promises.mkdir(targetPath, { recursive: true });
|
|
await copyDirectoryRecursive(sourcePath, targetPath, options, results);
|
|
} else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
// Copy markdown files
|
|
try {
|
|
if (!fs.existsSync(targetPath) || options.force) {
|
|
if (!options.dryRun) {
|
|
await fs.promises.copyFile(sourcePath, targetPath);
|
|
}
|
|
const relativePath = path.relative(targetDir, targetPath);
|
|
results.copiedFiles.push(relativePath);
|
|
if (!options.dryRun && options.verbose) {
|
|
console.log(` ✓ Copied ${relativePath}`);
|
|
}
|
|
} else {
|
|
const relativePath = path.relative(targetDir, targetPath);
|
|
results.skippedFiles.push(relativePath);
|
|
if (!options.dryRun && options.verbose) {
|
|
console.log(` ⏭️ Skipped ${relativePath} (already exists)`);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
results.errors.push(`Failed to copy ${entry.name}: ${err.message}`);
|
|
}
|
|
}
|
|
}
|
|
} catch (err) {
|
|
results.errors.push(`Failed to read directory ${sourceDir}: ${err.message}`);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Copy only specific categories
|
|
*/
|
|
export async function copyRevisedTemplatesByCategory(targetDir, categories, options = {}) {
|
|
const results = {
|
|
success: true,
|
|
copiedFiles: [],
|
|
skippedFiles: [],
|
|
errors: []
|
|
};
|
|
|
|
for (const category of categories) {
|
|
const sourceCategoryDir = path.join(REPO_TEMPLATES_DIR, category);
|
|
const targetCategoryDir = path.join(targetDir, '.claude/commands', category);
|
|
|
|
if (fs.existsSync(sourceCategoryDir)) {
|
|
await fs.promises.mkdir(targetCategoryDir, { recursive: true });
|
|
await copyDirectoryRecursive(sourceCategoryDir, targetCategoryDir, options, results);
|
|
} else {
|
|
results.errors.push(`Category '${category}' not found in templates`);
|
|
}
|
|
}
|
|
|
|
results.success = results.errors.length === 0;
|
|
return results;
|
|
}
|
|
|
|
/**
|
|
* Validate that source templates exist
|
|
*/
|
|
export function validateTemplatesExist() {
|
|
if (!fs.existsSync(REPO_TEMPLATES_DIR)) {
|
|
return {
|
|
valid: false,
|
|
error: `Template directory not found: ${REPO_TEMPLATES_DIR}`
|
|
};
|
|
}
|
|
|
|
const requiredCategories = ['analysis', 'github', 'sparc', 'coordination'];
|
|
const missingCategories = [];
|
|
|
|
for (const category of requiredCategories) {
|
|
const categoryPath = path.join(REPO_TEMPLATES_DIR, category);
|
|
if (!fs.existsSync(categoryPath)) {
|
|
missingCategories.push(category);
|
|
}
|
|
}
|
|
|
|
if (missingCategories.length > 0) {
|
|
return {
|
|
valid: false,
|
|
error: `Missing required template categories: ${missingCategories.join(', ')}`
|
|
};
|
|
}
|
|
|
|
return { valid: true };
|
|
} |