Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/init/agent-copier.js

rUv71e0fab1188d
diff --git a/.claude/checkpoints/1757192389.json b/.claude/checkpoints/1757192389.json
new file mode 100644
index 0000000000..00a0d9ac38
--- /dev/null
+++ b/.claude/checkpoints/1757192389.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250906-205949", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/init/templates/claude-md.js", "timestamp": "2025-09-06T20:59:49Z", "type": "pre-edit", "original_branch": "alpha101"}
diff --git a/.claude/checkpoints/1757192391.json b/.claude/checkpoints/1757192391.json
new file mode 100644
index 0000000000..c4d895d167
--- /dev/null
+++ b/.claude/checkpoints/1757192391.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250906-205951", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/init/templates/claude-md.js", "timestamp": "2025-09-06T20:59:51Z", "type": "post-edit", "branch": "alpha101", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 312 +++++++++++++++++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1757192316.json | 1 + .claude/checkpoints/1757192318.json | 1 + claude-flow-wiki | 0 .../simple-commands/init/templates/claude-md.js | 1 + 7 files changed, 319 insertions(+), 4 deletions(-) "}
diff --git a/src/cli/simple-commands/init/agent-copier.js b/src/cli/simple-commands/init/agent-copier.js
index b69b3b7187..ab553e9323 100644
--- a/src/cli/simple-commands/init/agent-copier.js
+++ b/src/cli/simple-commands/init/agent-copier.js
@@ -183,6 +183,131 @@ export async function createAgentDirectories(targetDir, dryRun = false) {
/**
* Validate agent system after copying
*/
+/**
+ * Copy all command files from the installed package to project directory
+ */
+export async function copyCommandFiles(targetDir, options = {}) {
+ const { force = false, dryRun = false } = options;
+
+ // Path to command files - try multiple locations
+ const packageCommandsDir = join(__dirname, '../../../../.claude/commands'); // From npm package
+ const localCommandsDir = '/workspaces/claude-code-flow/.claude/commands'; // Local development
+ const cwdCommandsDir = join(process.cwd(), '.claude/commands'); // Current working directory
+
+ let sourceCommandsDir;
+
+ // Try local development first, then package, then cwd
+ try {
+ await fs.access(localCommandsDir);
+ sourceCommandsDir = localCommandsDir;
+ console.log(' πŸ“ Using local development command files');
+ } catch {
+ try {
+ await fs.access(packageCommandsDir);
+ sourceCommandsDir = packageCommandsDir;
+ console.log(' πŸ“ Using packaged command files');
+ } catch {
+ try {
+ await fs.access(cwdCommandsDir);
+ sourceCommandsDir = cwdCommandsDir;
+ console.log(' πŸ“ Using current directory command files');
+ } catch {
+ console.log(' ⚠️ No command files found in any location');
+ return { success: false, error: 'Command files not found' };
+ }
+ }
+ }
+
+ const targetCommandsDir = join(targetDir, '.claude/commands');
+
+ console.log('πŸ“ Copying command system files...');
+ console.log(` πŸ“‚ Source: ${sourceCommandsDir}`);
+ console.log(` πŸ“‚ Target: ${targetCommandsDir}`);
+
+ try {
+ // Create target directory
+ if (!dryRun) {
+ await fs.mkdir(targetCommandsDir, { recursive: true });
+ }
+
+ const copiedFiles = [];
+ const errors = [];
+
+ // Recursively copy all command files
+ async function copyRecursive(srcDir, destDir) {
+ const items = await fs.readdir(srcDir, { withFileTypes: true });
+
+ for (const item of items) {
+ const srcPath = join(srcDir, item.name);
+ const destPath = join(destDir, item.name);
+
+ if (item.isDirectory()) {
+ if (!dryRun) {
+ await fs.mkdir(destPath, { recursive: true });
+ }
+ await copyRecursive(srcPath, destPath);
+ } else if (item.isFile() && item.name.endsWith('.md')) {
+ try {
+ // Check if file already exists
+ let shouldCopy = force;
+ if (!force) {
+ try {
+ await fs.access(destPath);
+ // File exists, skip unless force is true
+ continue;
+ } catch {
+ // File doesn't exist, safe to copy
+ shouldCopy = true;
+ }
+ }
+
+ if (shouldCopy && !dryRun) {
+ const content = await fs.readFile(srcPath, 'utf8');
+ await fs.writeFile(destPath, content, 'utf8');
+ copiedFiles.push(destPath.replace(targetDir + '/', ''));
+ } else if (dryRun) {
+ copiedFiles.push(destPath.replace(targetDir + '/', ''));
+ }
+ } catch (err) {
+ errors.push(`Failed to copy ${item.name}: ${err.message}`);
+ }
+ }
+ }
+ }
+
+ await copyRecursive(sourceCommandsDir, targetCommandsDir);
+
+ if (!dryRun && copiedFiles.length > 0) {
+ console.log(` βœ… Copied ${copiedFiles.length} command files`);
+ console.log(' πŸ“‹ Command system initialized with comprehensive documentation');
+ console.log(' 🎯 Available categories: Analysis, Automation, GitHub, Hooks, Memory, Flow Nexus');
+ } else if (dryRun) {
+ console.log(` [DRY RUN] Would copy ${copiedFiles.length} command files`);
+ }
+
+ if (errors.length > 0) {
+ console.log(' ⚠️ Some command files could not be copied:');
+ errors.forEach(error => console.log(` - ${error}`));
+ }
+
+ return {
+ success: true,
+ copiedFiles,
+ errors,
+ totalCommands: copiedFiles.length
+ };
+
+ } catch (err) {
+ console.log(` ❌ Failed to copy command files: ${err.message}`);
+ return {
+ success: false,
+ error: err.message,
+ copiedFiles: [],
+ errors: [err.message]
+ };
+ }
+}
+
export async function validateAgentSystem(targetDir) {
const agentsDir = join(targetDir, '.claude/agents');