claude-flow-novice 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/migration/README.md +434 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// sparc-structure.js - Create SPARC development structure
|
|
2
|
+
|
|
3
|
+
import { createBasicRoomodesConfig } from './sparc/roomodes-config.js';
|
|
4
|
+
import { errors } from '../../node-compat.js';
|
|
5
|
+
import { promises as fs } from 'fs';
|
|
6
|
+
import { createBasicSparcWorkflow } from './sparc/workflows.js';
|
|
7
|
+
import { createRooReadme } from './sparc/roo-readme.js';
|
|
8
|
+
import { createClaudeSlashCommands } from './claude-commands/slash-commands.js';
|
|
9
|
+
import { cwd } from '../../node-compat.js';
|
|
10
|
+
import process from 'process';
|
|
11
|
+
|
|
12
|
+
// Helper function to create SPARC structure manually
|
|
13
|
+
export async function createSparcStructureManually() {
|
|
14
|
+
try {
|
|
15
|
+
// Ensure we're in the working directory
|
|
16
|
+
const workingDir = process.env.PWD || cwd();
|
|
17
|
+
|
|
18
|
+
// Create .roo directory structure in working directory (legacy support)
|
|
19
|
+
const rooDirectories = [
|
|
20
|
+
`${workingDir}/.roo`,
|
|
21
|
+
`${workingDir}/.roo/templates`,
|
|
22
|
+
`${workingDir}/.roo/workflows`,
|
|
23
|
+
`${workingDir}/.roo/modes`,
|
|
24
|
+
`${workingDir}/.roo/configs`,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
for (const dir of rooDirectories) {
|
|
28
|
+
try {
|
|
29
|
+
await fs.mkdir(dir, { recursive: true });
|
|
30
|
+
console.log(` ✓ Created ${dir}/`);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (!(err instanceof errors.AlreadyExists)) {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Create .roomodes file (copy from existing if available, or create basic version)
|
|
39
|
+
let roomodesContent;
|
|
40
|
+
try {
|
|
41
|
+
// Check if .roomodes already exists and read it
|
|
42
|
+
roomodesContent = await fs.readFile(`${workingDir}/.roomodes`, 'utf8');
|
|
43
|
+
console.log(' ✓ Using existing .roomodes configuration');
|
|
44
|
+
} catch {
|
|
45
|
+
// Create basic .roomodes configuration
|
|
46
|
+
roomodesContent = createBasicRoomodesConfig();
|
|
47
|
+
await fs.writeFile(`${workingDir}/.roomodes`, roomodesContent, 'utf8');
|
|
48
|
+
console.log(' ✓ Created .roomodes configuration');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Create basic workflow templates
|
|
52
|
+
const basicWorkflow = createBasicSparcWorkflow();
|
|
53
|
+
await fs.writeFile(`${workingDir}/.roo/workflows/basic-tdd.json`, basicWorkflow, 'utf8');
|
|
54
|
+
console.log(' ✓ Created .roo/workflows/basic-tdd.json');
|
|
55
|
+
|
|
56
|
+
// Create README for .roo directory
|
|
57
|
+
const rooReadme = createRooReadme();
|
|
58
|
+
await fs.writeFile(`${workingDir}/.roo/README.md`, rooReadme, 'utf8');
|
|
59
|
+
console.log(' ✓ Created .roo/README.md');
|
|
60
|
+
|
|
61
|
+
// Create Claude Code slash commands for SPARC modes
|
|
62
|
+
await createClaudeSlashCommands(workingDir);
|
|
63
|
+
|
|
64
|
+
console.log(' ✅ Basic SPARC structure created successfully');
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.log(` ❌ Failed to create SPARC structure: ${err.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
// template-copier.js - Copy template files instead of generating them dynamically
|
|
2
|
+
|
|
3
|
+
import { existsSync } from '../../node-compat.js';
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import { dirname, join, relative } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copy template files from the templates directory to the target directory
|
|
13
|
+
* @param {string} targetDir - The directory to copy templates to
|
|
14
|
+
* @param {Object} options - Options for template copying
|
|
15
|
+
* @param {boolean} options.sparc - Whether to include SPARC templates
|
|
16
|
+
* @param {boolean} options.enhanced - Whether to use enhanced templates
|
|
17
|
+
* @param {boolean} options.minimal - Whether to use minimal templates
|
|
18
|
+
* @param {boolean} options.optimized - Whether to use optimized templates
|
|
19
|
+
* @param {boolean} options.dryRun - Whether to perform a dry run
|
|
20
|
+
* @param {boolean} options.force - Whether to overwrite existing files
|
|
21
|
+
* @param {string[]} options.selectedModes - Selected SPARC modes to copy
|
|
22
|
+
* @returns {Promise<{success: boolean, copiedFiles: string[], errors: string[]}>}
|
|
23
|
+
*/
|
|
24
|
+
export async function copyTemplates(targetDir, options = {}) {
|
|
25
|
+
const results = {
|
|
26
|
+
success: true,
|
|
27
|
+
copiedFiles: [],
|
|
28
|
+
errors: [],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const templatesDir = join(__dirname, 'templates');
|
|
33
|
+
|
|
34
|
+
// Determine which template variants to use
|
|
35
|
+
const templateVariant =
|
|
36
|
+
options.verify || options.pair
|
|
37
|
+
? 'verification'
|
|
38
|
+
: options.optimized
|
|
39
|
+
? 'optimized'
|
|
40
|
+
: options.enhanced
|
|
41
|
+
? 'enhanced'
|
|
42
|
+
: options.minimal
|
|
43
|
+
? 'minimal'
|
|
44
|
+
: options.sparc
|
|
45
|
+
? 'sparc'
|
|
46
|
+
: 'full';
|
|
47
|
+
|
|
48
|
+
// Core files to copy
|
|
49
|
+
const coreFiles = [
|
|
50
|
+
{
|
|
51
|
+
source: 'CLAUDE.md',
|
|
52
|
+
destination: 'CLAUDE.md',
|
|
53
|
+
useVariant: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
source: 'memory-bank.md',
|
|
57
|
+
destination: 'memory-bank.md',
|
|
58
|
+
useVariant: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
source: 'coordination.md',
|
|
62
|
+
destination: 'coordination.md',
|
|
63
|
+
useVariant: true,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
// Copy core files
|
|
68
|
+
for (const file of coreFiles) {
|
|
69
|
+
// Skip files if requested
|
|
70
|
+
if (options.skipClaudeMd && file.destination === 'CLAUDE.md') continue;
|
|
71
|
+
if (options.skipSettings && file.destination.includes('settings')) continue;
|
|
72
|
+
|
|
73
|
+
const sourceFile =
|
|
74
|
+
file.useVariant && existsSync(join(templatesDir, `${file.source}.${templateVariant}`))
|
|
75
|
+
? `${file.source}.${templateVariant}`
|
|
76
|
+
: file.source;
|
|
77
|
+
|
|
78
|
+
const sourcePath = join(templatesDir, sourceFile);
|
|
79
|
+
const destPath = join(targetDir, file.destination);
|
|
80
|
+
|
|
81
|
+
if (await copyFile(sourcePath, destPath, options)) {
|
|
82
|
+
results.copiedFiles.push(file.destination);
|
|
83
|
+
} else if (!options.dryRun) {
|
|
84
|
+
results.errors.push(`Failed to copy ${file.destination}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Copy .claude directory structure
|
|
89
|
+
if (options.enhanced || !options.minimal) {
|
|
90
|
+
const claudeDir = join(targetDir, '.claude');
|
|
91
|
+
|
|
92
|
+
// Copy settings.json unless skipped
|
|
93
|
+
if (!options.skipSettings) {
|
|
94
|
+
const settingsSource =
|
|
95
|
+
options.verify || options.pair
|
|
96
|
+
? 'settings.json.verification'
|
|
97
|
+
: options.enhanced
|
|
98
|
+
? 'settings.json.enhanced'
|
|
99
|
+
: 'settings.json';
|
|
100
|
+
const settingsPath = join(templatesDir, settingsSource);
|
|
101
|
+
const settingsDest = join(claudeDir, 'settings.json');
|
|
102
|
+
|
|
103
|
+
if (!options.dryRun) {
|
|
104
|
+
await fs.mkdir(claudeDir, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (await copyFile(settingsPath, settingsDest, options)) {
|
|
108
|
+
results.copiedFiles.push('.claude/settings.json');
|
|
109
|
+
}
|
|
110
|
+
} else if (!options.dryRun) {
|
|
111
|
+
// Still create the directory even if skipping settings
|
|
112
|
+
await fs.mkdir(claudeDir, { recursive: true });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Copy command templates
|
|
116
|
+
if (options.sparc || options.enhanced) {
|
|
117
|
+
await copyCommandTemplates(templatesDir, targetDir, options, results);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Copy helper scripts (enhanced mode only)
|
|
121
|
+
if (options.enhanced) {
|
|
122
|
+
await copyHelperScripts(templatesDir, targetDir, options, results);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Copy SPARC-specific files
|
|
127
|
+
if (options.sparc) {
|
|
128
|
+
await copySparcTemplates(templatesDir, targetDir, options, results);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Copy wrapper scripts
|
|
132
|
+
await copyWrapperScripts(templatesDir, targetDir, options, results);
|
|
133
|
+
|
|
134
|
+
// Create directory structure
|
|
135
|
+
await createDirectoryStructure(targetDir, options);
|
|
136
|
+
|
|
137
|
+
// Create README files for memory directories
|
|
138
|
+
await createMemoryReadmeFiles(targetDir, options, results);
|
|
139
|
+
} catch (err) {
|
|
140
|
+
results.success = false;
|
|
141
|
+
results.errors.push(`Template copy failed: ${err.message}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return results;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Copy a single file with options
|
|
149
|
+
*/
|
|
150
|
+
async function copyFile(source, destination, options) {
|
|
151
|
+
try {
|
|
152
|
+
// Check if source exists
|
|
153
|
+
if (!existsSync(source)) {
|
|
154
|
+
// Try reading from templates directory as fallback
|
|
155
|
+
const templateContent = await getTemplateContent(source);
|
|
156
|
+
if (templateContent) {
|
|
157
|
+
if (!options.dryRun) {
|
|
158
|
+
await fs.writeFile(destination, templateContent);
|
|
159
|
+
}
|
|
160
|
+
console.log(
|
|
161
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${relative(process.cwd(), destination)}`,
|
|
162
|
+
);
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
console.log(` ⚠️ Template not found: ${relative(process.cwd(), source)}`);
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Check if destination exists and handle force flag
|
|
170
|
+
if (existsSync(destination) && !options.force) {
|
|
171
|
+
console.log(
|
|
172
|
+
` ⚠️ File already exists: ${relative(process.cwd(), destination)} (use --force to overwrite)`,
|
|
173
|
+
);
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!options.dryRun) {
|
|
178
|
+
// Ensure destination directory exists
|
|
179
|
+
await fs.mkdir(dirname(destination), { recursive: true });
|
|
180
|
+
|
|
181
|
+
// Copy the file
|
|
182
|
+
const content = await fs.readFile(source, 'utf8');
|
|
183
|
+
await fs.writeFile(destination, content);
|
|
184
|
+
|
|
185
|
+
// Preserve file permissions for executable scripts
|
|
186
|
+
if (source.endsWith('.sh') || source.includes('claude-flow')) {
|
|
187
|
+
await fs.chmod(destination, 0o755);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
console.log(
|
|
192
|
+
` ${options.dryRun ? '[DRY RUN] Would copy' : '✓ Copied'} ${relative(process.cwd(), destination)}`,
|
|
193
|
+
);
|
|
194
|
+
return true;
|
|
195
|
+
} catch (err) {
|
|
196
|
+
console.log(` ❌ Failed to copy ${relative(process.cwd(), destination)}: ${err.message}`);
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Copy command templates
|
|
203
|
+
*/
|
|
204
|
+
async function copyCommandTemplates(templatesDir, targetDir, options, results) {
|
|
205
|
+
const commandsSourceDir = join(templatesDir, 'commands');
|
|
206
|
+
const commandsDestDir = join(targetDir, '.claude', 'commands');
|
|
207
|
+
|
|
208
|
+
if (!existsSync(commandsSourceDir)) {
|
|
209
|
+
// Use generated command templates as fallback
|
|
210
|
+
return await generateCommandTemplates(targetDir, options, results);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
if (!options.dryRun) {
|
|
215
|
+
await fs.mkdir(commandsDestDir, { recursive: true });
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Copy command categories
|
|
219
|
+
const categories = await fs.readdir(commandsSourceDir);
|
|
220
|
+
|
|
221
|
+
for (const category of categories) {
|
|
222
|
+
const categoryPath = join(commandsSourceDir, category);
|
|
223
|
+
const stat = await fs.stat(categoryPath);
|
|
224
|
+
|
|
225
|
+
if (stat.isDirectory()) {
|
|
226
|
+
const destCategoryPath = join(commandsDestDir, category);
|
|
227
|
+
|
|
228
|
+
if (!options.dryRun) {
|
|
229
|
+
await fs.mkdir(destCategoryPath, { recursive: true });
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Copy files in category
|
|
233
|
+
const files = await fs.readdir(categoryPath);
|
|
234
|
+
for (const file of files) {
|
|
235
|
+
const sourcePath = join(categoryPath, file);
|
|
236
|
+
const destPath = join(destCategoryPath, file);
|
|
237
|
+
|
|
238
|
+
if (await copyFile(sourcePath, destPath, options)) {
|
|
239
|
+
results.copiedFiles.push(join('.claude', 'commands', category, file));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
results.errors.push(`Failed to copy command templates: ${err.message}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Copy SPARC templates
|
|
251
|
+
*/
|
|
252
|
+
async function copySparcTemplates(templatesDir, targetDir, options, results) {
|
|
253
|
+
const sparcDir = join(targetDir, '.claude', 'commands', 'sparc');
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
if (!options.dryRun) {
|
|
257
|
+
await fs.mkdir(sparcDir, { recursive: true });
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Get SPARC mode templates
|
|
261
|
+
const { createSparcModeTemplates, createSparcModesOverview } = await import(
|
|
262
|
+
'./templates/sparc-modes.js'
|
|
263
|
+
);
|
|
264
|
+
const sparcTemplates = createSparcModeTemplates();
|
|
265
|
+
|
|
266
|
+
// Filter templates if selectedModes is specified
|
|
267
|
+
const templatesToCreate = options.selectedModes
|
|
268
|
+
? Object.entries(sparcTemplates).filter(([filename]) => {
|
|
269
|
+
const mode = filename.replace('.md', '');
|
|
270
|
+
return options.selectedModes.includes(mode);
|
|
271
|
+
})
|
|
272
|
+
: Object.entries(sparcTemplates);
|
|
273
|
+
|
|
274
|
+
// Write SPARC mode files
|
|
275
|
+
for (const [filename, content] of templatesToCreate) {
|
|
276
|
+
const destPath = join(sparcDir, filename);
|
|
277
|
+
|
|
278
|
+
if (!options.dryRun) {
|
|
279
|
+
await fs.writeFile(destPath, content);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
console.log(
|
|
283
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/commands/sparc/${filename}`,
|
|
284
|
+
);
|
|
285
|
+
results.copiedFiles.push(join('.claude', 'commands', 'sparc', filename));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Create sparc-modes.md overview
|
|
289
|
+
const overviewPath = join(sparcDir, 'sparc-modes.md');
|
|
290
|
+
if (!options.dryRun) {
|
|
291
|
+
await fs.writeFile(overviewPath, createSparcModesOverview());
|
|
292
|
+
}
|
|
293
|
+
console.log(
|
|
294
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/commands/sparc/sparc-modes.md`,
|
|
295
|
+
);
|
|
296
|
+
results.copiedFiles.push('.claude/commands/sparc/sparc-modes.md');
|
|
297
|
+
|
|
298
|
+
// Copy swarm templates
|
|
299
|
+
await copySwarmTemplates(templatesDir, targetDir, options, results);
|
|
300
|
+
} catch (err) {
|
|
301
|
+
results.errors.push(`Failed to copy SPARC templates: ${err.message}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Copy swarm strategy templates
|
|
307
|
+
*/
|
|
308
|
+
async function copySwarmTemplates(templatesDir, targetDir, options, results) {
|
|
309
|
+
const swarmDir = join(targetDir, '.claude', 'commands', 'swarm');
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
if (!options.dryRun) {
|
|
313
|
+
await fs.mkdir(swarmDir, { recursive: true });
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Get swarm strategy templates
|
|
317
|
+
const { createSwarmStrategyTemplates } = await import('./templates/sparc-modes.js');
|
|
318
|
+
const swarmTemplates = createSwarmStrategyTemplates();
|
|
319
|
+
|
|
320
|
+
// Write swarm strategy files
|
|
321
|
+
for (const [filename, content] of Object.entries(swarmTemplates)) {
|
|
322
|
+
const destPath = join(swarmDir, filename);
|
|
323
|
+
|
|
324
|
+
if (!options.dryRun) {
|
|
325
|
+
await fs.writeFile(destPath, content);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
console.log(
|
|
329
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/commands/swarm/${filename}`,
|
|
330
|
+
);
|
|
331
|
+
results.copiedFiles.push(join('.claude', 'commands', 'swarm', filename));
|
|
332
|
+
}
|
|
333
|
+
} catch (err) {
|
|
334
|
+
results.errors.push(`Failed to copy swarm templates: ${err.message}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Copy helper scripts (enhanced mode)
|
|
340
|
+
*/
|
|
341
|
+
async function copyHelperScripts(templatesDir, targetDir, options, results) {
|
|
342
|
+
const helpersDir = join(targetDir, '.claude', 'helpers');
|
|
343
|
+
|
|
344
|
+
try {
|
|
345
|
+
if (!options.dryRun) {
|
|
346
|
+
await fs.mkdir(helpersDir, { recursive: true });
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const helpers = [
|
|
350
|
+
'setup-mcp.sh',
|
|
351
|
+
'quick-start.sh',
|
|
352
|
+
'github-setup.sh',
|
|
353
|
+
'github-safe.js',
|
|
354
|
+
'checkpoint-manager.sh',
|
|
355
|
+
'standard-checkpoint-hooks.sh',
|
|
356
|
+
];
|
|
357
|
+
const { createHelperScript } = await import('./templates/enhanced-templates.js');
|
|
358
|
+
|
|
359
|
+
for (const helper of helpers) {
|
|
360
|
+
const content = createHelperScript(helper);
|
|
361
|
+
if (content) {
|
|
362
|
+
const destPath = join(helpersDir, helper);
|
|
363
|
+
|
|
364
|
+
if (!options.dryRun) {
|
|
365
|
+
await fs.writeFile(destPath, content);
|
|
366
|
+
await fs.chmod(destPath, 0o755);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
console.log(
|
|
370
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/helpers/${helper}`,
|
|
371
|
+
);
|
|
372
|
+
results.copiedFiles.push(join('.claude', 'helpers', helper));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} catch (err) {
|
|
376
|
+
results.errors.push(`Failed to copy helper scripts: ${err.message}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Copy wrapper scripts
|
|
382
|
+
*/
|
|
383
|
+
async function copyWrapperScripts(templatesDir, targetDir, options, results) {
|
|
384
|
+
try {
|
|
385
|
+
// Unix wrapper
|
|
386
|
+
const unixWrapperPath = join(targetDir, 'claude-flow');
|
|
387
|
+
const unixWrapperSource = join(templatesDir, 'claude-flow-universal');
|
|
388
|
+
|
|
389
|
+
if (await copyFile(unixWrapperSource, unixWrapperPath, options)) {
|
|
390
|
+
if (!options.dryRun) {
|
|
391
|
+
await fs.chmod(unixWrapperPath, 0o755);
|
|
392
|
+
}
|
|
393
|
+
results.copiedFiles.push('claude-flow');
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Windows batch wrapper
|
|
397
|
+
const batchWrapperPath = join(targetDir, 'claude-flow.bat');
|
|
398
|
+
const batchWrapperSource = join(templatesDir, 'claude-flow.bat');
|
|
399
|
+
|
|
400
|
+
if (await copyFile(batchWrapperSource, batchWrapperPath, options)) {
|
|
401
|
+
results.copiedFiles.push('claude-flow.bat');
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// PowerShell wrapper
|
|
405
|
+
const psWrapperPath = join(targetDir, 'claude-flow.ps1');
|
|
406
|
+
const psWrapperSource = join(templatesDir, 'claude-flow.ps1');
|
|
407
|
+
|
|
408
|
+
if (await copyFile(psWrapperSource, psWrapperPath, options)) {
|
|
409
|
+
results.copiedFiles.push('claude-flow.ps1');
|
|
410
|
+
}
|
|
411
|
+
} catch (err) {
|
|
412
|
+
results.errors.push(`Failed to copy wrapper scripts: ${err.message}`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Create directory structure
|
|
418
|
+
*/
|
|
419
|
+
async function createDirectoryStructure(targetDir, options) {
|
|
420
|
+
const directories = [
|
|
421
|
+
'memory',
|
|
422
|
+
'memory/agents',
|
|
423
|
+
'memory/sessions',
|
|
424
|
+
'coordination',
|
|
425
|
+
'coordination/memory_bank',
|
|
426
|
+
'coordination/subtasks',
|
|
427
|
+
'coordination/orchestration',
|
|
428
|
+
'.claude',
|
|
429
|
+
'.claude/commands',
|
|
430
|
+
'.claude/logs',
|
|
431
|
+
'.swarm', // For memory persistence
|
|
432
|
+
];
|
|
433
|
+
|
|
434
|
+
if (options.sparc) {
|
|
435
|
+
directories.push('.claude/commands/sparc', '.claude/commands/swarm');
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
for (const dir of directories) {
|
|
439
|
+
const dirPath = join(targetDir, dir);
|
|
440
|
+
try {
|
|
441
|
+
if (!options.dryRun) {
|
|
442
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
443
|
+
}
|
|
444
|
+
console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${dir}/ directory`);
|
|
445
|
+
} catch (err) {
|
|
446
|
+
if (err.code !== 'EEXIST') {
|
|
447
|
+
console.log(` ❌ Failed to create ${dir}/: ${err.message}`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Create README files for memory directories
|
|
455
|
+
*/
|
|
456
|
+
async function createMemoryReadmeFiles(targetDir, options, results) {
|
|
457
|
+
const { createAgentsReadme, createSessionsReadme } = await import('./templates/readme-files.js');
|
|
458
|
+
|
|
459
|
+
const readmeFiles = [
|
|
460
|
+
{ path: 'memory/agents/README.md', content: createAgentsReadme() },
|
|
461
|
+
{ path: 'memory/sessions/README.md', content: createSessionsReadme() },
|
|
462
|
+
];
|
|
463
|
+
|
|
464
|
+
for (const { path, content } of readmeFiles) {
|
|
465
|
+
const fullPath = join(targetDir, path);
|
|
466
|
+
|
|
467
|
+
try {
|
|
468
|
+
if (!options.dryRun) {
|
|
469
|
+
await fs.mkdir(dirname(fullPath), { recursive: true });
|
|
470
|
+
await fs.writeFile(fullPath, content);
|
|
471
|
+
}
|
|
472
|
+
console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${path}`);
|
|
473
|
+
results.copiedFiles.push(path);
|
|
474
|
+
} catch (err) {
|
|
475
|
+
results.errors.push(`Failed to create ${path}: ${err.message}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Initialize persistence database
|
|
480
|
+
const dbPath = join(targetDir, 'memory', 'claude-flow-data.json');
|
|
481
|
+
const initialData = {
|
|
482
|
+
agents: [],
|
|
483
|
+
tasks: [],
|
|
484
|
+
lastUpdated: Date.now(),
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
try {
|
|
488
|
+
if (!options.dryRun) {
|
|
489
|
+
await fs.writeFile(dbPath, JSON.stringify(initialData, null, 2));
|
|
490
|
+
}
|
|
491
|
+
console.log(
|
|
492
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} memory/claude-flow-data.json (persistence database)`,
|
|
493
|
+
);
|
|
494
|
+
results.copiedFiles.push('memory/claude-flow-data.json');
|
|
495
|
+
} catch (err) {
|
|
496
|
+
results.errors.push(`Failed to create persistence database: ${err.message}`);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Get template content as fallback (for backwards compatibility)
|
|
502
|
+
*/
|
|
503
|
+
async function getTemplateContent(templatePath) {
|
|
504
|
+
const filename = templatePath.split('/').pop();
|
|
505
|
+
|
|
506
|
+
// Map template files to their generator functions
|
|
507
|
+
const templateGenerators = {
|
|
508
|
+
'CLAUDE.md': async () => {
|
|
509
|
+
const { createFullClaudeMd } = await import('./templates/claude-md.js');
|
|
510
|
+
return createFullClaudeMd();
|
|
511
|
+
},
|
|
512
|
+
'CLAUDE.md.sparc': async () => {
|
|
513
|
+
const { createSparcClaudeMd } = await import('./templates/claude-md.js');
|
|
514
|
+
return createSparcClaudeMd();
|
|
515
|
+
},
|
|
516
|
+
'CLAUDE.md.minimal': async () => {
|
|
517
|
+
const { createMinimalClaudeMd } = await import('./templates/claude-md.js');
|
|
518
|
+
return createMinimalClaudeMd();
|
|
519
|
+
},
|
|
520
|
+
'CLAUDE.md.optimized': async () => {
|
|
521
|
+
const { createOptimizedSparcClaudeMd } = await import('./templates/claude-md.js');
|
|
522
|
+
return createOptimizedSparcClaudeMd();
|
|
523
|
+
},
|
|
524
|
+
'CLAUDE.md.enhanced': async () => {
|
|
525
|
+
const { createEnhancedClaudeMd } = await import('./templates/enhanced-templates.js');
|
|
526
|
+
return createEnhancedClaudeMd();
|
|
527
|
+
},
|
|
528
|
+
'CLAUDE.md.verification': async () => {
|
|
529
|
+
const { createVerificationClaudeMd } = await import('./templates/verification-claude-md.js');
|
|
530
|
+
return createVerificationClaudeMd();
|
|
531
|
+
},
|
|
532
|
+
'memory-bank.md': async () => {
|
|
533
|
+
const { createFullMemoryBankMd } = await import('./templates/memory-bank-md.js');
|
|
534
|
+
return createFullMemoryBankMd();
|
|
535
|
+
},
|
|
536
|
+
'memory-bank.md.minimal': async () => {
|
|
537
|
+
const { createMinimalMemoryBankMd } = await import('./templates/memory-bank-md.js');
|
|
538
|
+
return createMinimalMemoryBankMd();
|
|
539
|
+
},
|
|
540
|
+
'memory-bank.md.optimized': async () => {
|
|
541
|
+
const { createOptimizedMemoryBankMd } = await import('./templates/memory-bank-md.js');
|
|
542
|
+
return createOptimizedMemoryBankMd();
|
|
543
|
+
},
|
|
544
|
+
'coordination.md': async () => {
|
|
545
|
+
const { createFullCoordinationMd } = await import('./templates/coordination-md.js');
|
|
546
|
+
return createFullCoordinationMd();
|
|
547
|
+
},
|
|
548
|
+
'coordination.md.minimal': async () => {
|
|
549
|
+
const { createMinimalCoordinationMd } = await import('./templates/coordination-md.js');
|
|
550
|
+
return createMinimalCoordinationMd();
|
|
551
|
+
},
|
|
552
|
+
'coordination.md.optimized': async () => {
|
|
553
|
+
const { createOptimizedCoordinationMd } = await import('./templates/coordination-md.js');
|
|
554
|
+
return createOptimizedCoordinationMd();
|
|
555
|
+
},
|
|
556
|
+
'settings.json': async () => {
|
|
557
|
+
return await fs.readFile(join(__dirname, 'templates', 'settings.json'), 'utf8');
|
|
558
|
+
},
|
|
559
|
+
'settings.json.enhanced': async () => {
|
|
560
|
+
const { createEnhancedSettingsJson } = await import('./templates/enhanced-templates.js');
|
|
561
|
+
return createEnhancedSettingsJson();
|
|
562
|
+
},
|
|
563
|
+
'settings.json.verification': async () => {
|
|
564
|
+
const { createVerificationSettingsJson } = await import(
|
|
565
|
+
'./templates/verification-claude-md.js'
|
|
566
|
+
);
|
|
567
|
+
return createVerificationSettingsJson();
|
|
568
|
+
},
|
|
569
|
+
'claude-flow-universal': async () => {
|
|
570
|
+
return await fs.readFile(join(__dirname, 'templates', 'claude-flow-universal'), 'utf8');
|
|
571
|
+
},
|
|
572
|
+
'claude-flow.bat': async () => {
|
|
573
|
+
return await fs.readFile(join(__dirname, 'templates', 'claude-flow.bat'), 'utf8');
|
|
574
|
+
},
|
|
575
|
+
'claude-flow.ps1': async () => {
|
|
576
|
+
return await fs.readFile(join(__dirname, 'templates', 'claude-flow.ps1'), 'utf8');
|
|
577
|
+
},
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
const generator =
|
|
581
|
+
templateGenerators[filename] ||
|
|
582
|
+
templateGenerators[filename.replace(/\.(sparc|minimal|optimized|enhanced)$/, '')];
|
|
583
|
+
|
|
584
|
+
if (generator) {
|
|
585
|
+
try {
|
|
586
|
+
return await generator();
|
|
587
|
+
} catch (err) {
|
|
588
|
+
console.log(` ⚠️ Failed to generate template content for ${filename}: ${err.message}`);
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Generate command templates as fallback
|
|
598
|
+
*/
|
|
599
|
+
async function generateCommandTemplates(targetDir, options, results) {
|
|
600
|
+
const { COMMAND_STRUCTURE, createCommandDoc } = await import('./templates/enhanced-templates.js');
|
|
601
|
+
|
|
602
|
+
for (const [category, commands] of Object.entries(COMMAND_STRUCTURE)) {
|
|
603
|
+
const categoryDir = join(targetDir, '.claude', 'commands', category);
|
|
604
|
+
|
|
605
|
+
try {
|
|
606
|
+
if (!options.dryRun) {
|
|
607
|
+
await fs.mkdir(categoryDir, { recursive: true });
|
|
608
|
+
|
|
609
|
+
// Create category README
|
|
610
|
+
const categoryReadme = `# ${category.charAt(0).toUpperCase() + category.slice(1)} Commands
|
|
611
|
+
|
|
612
|
+
Commands for ${category} operations in Claude Flow.
|
|
613
|
+
|
|
614
|
+
## Available Commands
|
|
615
|
+
|
|
616
|
+
${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
|
|
617
|
+
`;
|
|
618
|
+
await fs.writeFile(join(categoryDir, 'README.md'), categoryReadme);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// Create individual command docs
|
|
622
|
+
for (const command of commands) {
|
|
623
|
+
const doc = createCommandDoc(category, command);
|
|
624
|
+
if (doc) {
|
|
625
|
+
const docPath = join(categoryDir, `${command}.md`);
|
|
626
|
+
if (!options.dryRun) {
|
|
627
|
+
await fs.writeFile(docPath, doc);
|
|
628
|
+
}
|
|
629
|
+
results.copiedFiles.push(join('.claude', 'commands', category, `${command}.md`));
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
console.log(
|
|
634
|
+
` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${commands.length} ${category} command docs`,
|
|
635
|
+
);
|
|
636
|
+
} catch (err) {
|
|
637
|
+
results.errors.push(`Failed to generate ${category} command templates: ${err.message}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|