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,769 @@
|
|
|
1
|
+
# Claude Code Configuration - SPARC Development Environment (JavaScript/Node.js)
|
|
2
|
+
|
|
3
|
+
## 🚨 CRITICAL: CONCURRENT EXECUTION & FILE MANAGEMENT
|
|
4
|
+
|
|
5
|
+
**ABSOLUTE RULES**:
|
|
6
|
+
1. ALL operations MUST be concurrent/parallel in a single message
|
|
7
|
+
2. **NEVER save working files, text/mds and tests to the root folder**
|
|
8
|
+
3. ALWAYS organize files in appropriate subdirectories
|
|
9
|
+
4. **USE CLAUDE CODE'S TASK TOOL** for spawning agents concurrently, not just MCP
|
|
10
|
+
|
|
11
|
+
### ⚡ GOLDEN RULE: "1 MESSAGE = ALL RELATED OPERATIONS"
|
|
12
|
+
|
|
13
|
+
**MANDATORY PATTERNS:**
|
|
14
|
+
- **TodoWrite**: ALWAYS batch ALL todos in ONE call (5-10+ todos minimum)
|
|
15
|
+
- **Task tool (Claude Code)**: ALWAYS spawn ALL agents in ONE message with full instructions
|
|
16
|
+
- **File operations**: ALWAYS batch ALL reads/writes/edits in ONE message
|
|
17
|
+
- **Bash commands**: ALWAYS batch ALL terminal operations in ONE message
|
|
18
|
+
- **Memory operations**: ALWAYS batch ALL memory store/retrieve in ONE message
|
|
19
|
+
|
|
20
|
+
### 🎯 CRITICAL: Claude Code Task Tool for Agent Execution
|
|
21
|
+
|
|
22
|
+
**Claude Code's Task tool is the PRIMARY way to spawn agents:**
|
|
23
|
+
```javascript
|
|
24
|
+
// ✅ CORRECT: Use Claude Code's Task tool for parallel agent execution
|
|
25
|
+
[Single Message]:
|
|
26
|
+
Task("JS researcher", "Analyze Node.js patterns and npm ecosystem...", "researcher")
|
|
27
|
+
Task("JS coder", "Implement core JavaScript modules with modern ES6+...", "coder")
|
|
28
|
+
Task("JS tester", "Create comprehensive tests with Jest/Mocha...", "tester")
|
|
29
|
+
Task("JS reviewer", "Review code for JavaScript best practices and ESLint...", "reviewer")
|
|
30
|
+
Task("JS architect", "Design system architecture with JavaScript patterns...", "system-architect")
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 📁 JavaScript File Organization Rules
|
|
34
|
+
|
|
35
|
+
**NEVER save to root folder. Use JavaScript project structure:**
|
|
36
|
+
- `/src` - Source code files (main modules, utilities)
|
|
37
|
+
- `/lib` - Compiled/built JavaScript files
|
|
38
|
+
- `/test` or `/tests` - Test files
|
|
39
|
+
- `/docs` - Documentation and markdown files
|
|
40
|
+
- `/config` - Configuration files
|
|
41
|
+
- `/scripts` - Build and utility scripts
|
|
42
|
+
- `/public` - Static assets (for web projects)
|
|
43
|
+
- `/node_modules` - Dependencies (auto-generated, add to .gitignore)
|
|
44
|
+
- `package.json` - Project manifest and dependencies
|
|
45
|
+
- `package-lock.json` - Dependency lock file
|
|
46
|
+
|
|
47
|
+
## Project Overview
|
|
48
|
+
|
|
49
|
+
This JavaScript/Node.js project uses SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) methodology with Claude-Flow orchestration for systematic Test-Driven Development.
|
|
50
|
+
|
|
51
|
+
## JavaScript-Specific SPARC Commands
|
|
52
|
+
|
|
53
|
+
### Core Commands
|
|
54
|
+
- `npx claude-flow sparc modes` - List available modes
|
|
55
|
+
- `npx claude-flow sparc run <mode> "<js-task>"` - Execute JavaScript-specific mode
|
|
56
|
+
- `npx claude-flow sparc tdd "<js-feature>"` - Run complete TDD workflow for JavaScript
|
|
57
|
+
- `npx claude-flow sparc info <mode>` - Get mode details
|
|
58
|
+
|
|
59
|
+
### JavaScript Build Commands
|
|
60
|
+
- `npm install` - Install dependencies
|
|
61
|
+
- `npm start` - Start development server
|
|
62
|
+
- `npm run build` - Build for production
|
|
63
|
+
- `npm test` - Run tests
|
|
64
|
+
- `npm run test:watch` - Run tests in watch mode
|
|
65
|
+
- `npm run test:coverage` - Run tests with coverage
|
|
66
|
+
- `npm run lint` - Run ESLint
|
|
67
|
+
- `npm run lint:fix` - Fix ESLint issues automatically
|
|
68
|
+
- `npm run format` - Format code with Prettier
|
|
69
|
+
- `npm run dev` - Development mode with hot reload
|
|
70
|
+
- `npm audit` - Security audit
|
|
71
|
+
- `npm outdated` - Check outdated dependencies
|
|
72
|
+
|
|
73
|
+
### JavaScript Quality Commands
|
|
74
|
+
- `npm run lint -- --fix` - Auto-fix linting issues
|
|
75
|
+
- `npm run test -- --coverage` - Generate test coverage report
|
|
76
|
+
- `npm run validate` - Run all quality checks
|
|
77
|
+
- `npx madge --circular src/` - Check for circular dependencies
|
|
78
|
+
|
|
79
|
+
## JavaScript SPARC Workflow Phases
|
|
80
|
+
|
|
81
|
+
1. **Specification** - Requirements analysis with JavaScript ecosystem (`sparc run spec-pseudocode`)
|
|
82
|
+
2. **Pseudocode** - Algorithm design with async/await patterns (`sparc run spec-pseudocode`)
|
|
83
|
+
3. **Architecture** - System design with Node.js patterns (`sparc run architect`)
|
|
84
|
+
4. **Refinement** - TDD implementation with Jest/Mocha (`sparc tdd`)
|
|
85
|
+
5. **Completion** - Integration with npm scripts (`sparc run integration`)
|
|
86
|
+
|
|
87
|
+
## JavaScript Code Style & Best Practices
|
|
88
|
+
|
|
89
|
+
- **Modern ES6+**: Use const/let, arrow functions, destructuring, modules
|
|
90
|
+
- **Async Programming**: Prefer async/await over callbacks and promises
|
|
91
|
+
- **Error Handling**: Use try/catch blocks and proper error objects
|
|
92
|
+
- **Functional Programming**: Immutable data, pure functions, higher-order functions
|
|
93
|
+
- **Testing**: Comprehensive unit and integration tests
|
|
94
|
+
- **Documentation**: JSDoc comments for public APIs
|
|
95
|
+
- **Linting**: ESLint with Airbnb or Standard config
|
|
96
|
+
- **Formatting**: Prettier for consistent code style
|
|
97
|
+
|
|
98
|
+
## 🚀 JavaScript-Specific Agents (78+ Total)
|
|
99
|
+
|
|
100
|
+
### Core JavaScript Development
|
|
101
|
+
`js-coder`, `node-developer`, `frontend-dev`, `js-tester`, `js-reviewer`, `js-architect`
|
|
102
|
+
|
|
103
|
+
### Frontend Specialists
|
|
104
|
+
`react-dev`, `vue-dev`, `angular-dev`, `vanilla-js-expert`, `dom-specialist`
|
|
105
|
+
|
|
106
|
+
### Backend Specialists
|
|
107
|
+
`express-dev`, `fastify-dev`, `nest-developer`, `api-designer`, `microservices-architect`
|
|
108
|
+
|
|
109
|
+
### Testing & Quality
|
|
110
|
+
`jest-expert`, `cypress-tester`, `playwright-tester`, `unit-test-specialist`, `e2e-tester`
|
|
111
|
+
|
|
112
|
+
### Build & Tooling
|
|
113
|
+
`webpack-expert`, `vite-specialist`, `babel-config`, `npm-expert`, `yarn-specialist`
|
|
114
|
+
|
|
115
|
+
### All Standard Agents Available
|
|
116
|
+
`coder`, `reviewer`, `tester`, `planner`, `researcher`, `system-architect`, `code-analyzer`, `performance-benchmarker`, `cicd-engineer`, `security-manager`
|
|
117
|
+
|
|
118
|
+
## 🎯 JavaScript Development Patterns
|
|
119
|
+
|
|
120
|
+
### ✅ CORRECT JAVASCRIPT WORKFLOW
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
// Step 1: Set up JavaScript project coordination
|
|
124
|
+
[Single Message - Coordination Setup]:
|
|
125
|
+
mcp__claude-flow__swarm_init { topology: "mesh", maxAgents: 6 }
|
|
126
|
+
mcp__claude-flow__agent_spawn { type: "js-architect" }
|
|
127
|
+
mcp__claude-flow__agent_spawn { type: "node-developer" }
|
|
128
|
+
mcp__claude-flow__agent_spawn { type: "js-tester" }
|
|
129
|
+
|
|
130
|
+
// Step 2: Parallel JavaScript development execution
|
|
131
|
+
[Single Message - Parallel Agent Execution]:
|
|
132
|
+
Task("JS architect", "Design modular architecture with ES6 modules. Store patterns in memory.", "js-architect")
|
|
133
|
+
Task("Node developer", "Implement server with Express/Fastify. Use async/await patterns.", "node-developer")
|
|
134
|
+
Task("Frontend developer", "Create responsive UI with modern JavaScript. Coordinate via hooks.", "frontend-dev")
|
|
135
|
+
Task("JS tester", "Create comprehensive test suite with Jest. Include unit and integration tests.", "js-tester")
|
|
136
|
+
Task("Build engineer", "Set up webpack/vite build process. Configure for development and production.", "webpack-expert")
|
|
137
|
+
|
|
138
|
+
// Batch ALL JavaScript todos
|
|
139
|
+
TodoWrite { todos: [
|
|
140
|
+
{content: "Set up package.json with dependencies", status: "in_progress", activeForm: "Setting up package.json"},
|
|
141
|
+
{content: "Implement core modules with ES6+", status: "pending", activeForm: "Implementing core modules"},
|
|
142
|
+
{content: "Add comprehensive Jest tests", status: "pending", activeForm: "Adding comprehensive Jest tests"},
|
|
143
|
+
{content: "Configure ESLint and Prettier", status: "pending", activeForm: "Configuring ESLint and Prettier"},
|
|
144
|
+
{content: "Set up build process with Webpack/Vite", status: "pending", activeForm: "Setting up build process"},
|
|
145
|
+
{content: "Add JSDoc documentation", status: "pending", activeForm: "Adding JSDoc documentation"},
|
|
146
|
+
{content: "Configure CI/CD pipeline", status: "pending", activeForm: "Configuring CI/CD pipeline"},
|
|
147
|
+
{content: "Add security scanning with npm audit", status: "pending", activeForm: "Adding security scanning"}
|
|
148
|
+
]}
|
|
149
|
+
|
|
150
|
+
// Parallel JavaScript file operations
|
|
151
|
+
Write "package.json"
|
|
152
|
+
Write "src/index.js"
|
|
153
|
+
Write "src/server.js"
|
|
154
|
+
Write "test/index.test.js"
|
|
155
|
+
Write ".eslintrc.js"
|
|
156
|
+
Write "webpack.config.js"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## JavaScript Agent Coordination Protocol
|
|
160
|
+
|
|
161
|
+
### Every JavaScript Agent MUST:
|
|
162
|
+
|
|
163
|
+
**1️⃣ BEFORE Work:**
|
|
164
|
+
```bash
|
|
165
|
+
npx claude-flow@alpha hooks pre-task --description "[js-task]"
|
|
166
|
+
npm install # Install dependencies
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**2️⃣ DURING Work:**
|
|
170
|
+
```bash
|
|
171
|
+
npm run lint # Check code quality
|
|
172
|
+
npm test # Run tests
|
|
173
|
+
npx claude-flow@alpha hooks post-edit --file "[file]" --memory-key "js/[agent]/[step]"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**3️⃣ AFTER Work:**
|
|
177
|
+
```bash
|
|
178
|
+
npm run build # Build project
|
|
179
|
+
npm audit # Security check
|
|
180
|
+
npx claude-flow@alpha hooks post-task --task-id "[task]"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## JavaScript-Specific Configurations
|
|
184
|
+
|
|
185
|
+
### package.json Template
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"name": "project-name",
|
|
189
|
+
"version": "1.0.0",
|
|
190
|
+
"description": "Project description",
|
|
191
|
+
"main": "src/index.js",
|
|
192
|
+
"scripts": {
|
|
193
|
+
"start": "node src/index.js",
|
|
194
|
+
"dev": "nodemon src/index.js",
|
|
195
|
+
"build": "webpack --mode production",
|
|
196
|
+
"build:dev": "webpack --mode development",
|
|
197
|
+
"test": "jest",
|
|
198
|
+
"test:watch": "jest --watch",
|
|
199
|
+
"test:coverage": "jest --coverage",
|
|
200
|
+
"lint": "eslint src/",
|
|
201
|
+
"lint:fix": "eslint src/ --fix",
|
|
202
|
+
"format": "prettier --write src/",
|
|
203
|
+
"validate": "npm run lint && npm run test",
|
|
204
|
+
"audit:fix": "npm audit fix"
|
|
205
|
+
},
|
|
206
|
+
"keywords": ["javascript", "node", "api"],
|
|
207
|
+
"author": "Your Name <email@example.com>",
|
|
208
|
+
"license": "MIT",
|
|
209
|
+
"dependencies": {
|
|
210
|
+
"express": "^4.18.0",
|
|
211
|
+
"cors": "^2.8.5",
|
|
212
|
+
"helmet": "^6.0.0",
|
|
213
|
+
"dotenv": "^16.0.0"
|
|
214
|
+
},
|
|
215
|
+
"devDependencies": {
|
|
216
|
+
"@types/node": "^18.0.0",
|
|
217
|
+
"eslint": "^8.0.0",
|
|
218
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
219
|
+
"eslint-plugin-import": "^2.25.0",
|
|
220
|
+
"jest": "^29.0.0",
|
|
221
|
+
"nodemon": "^2.0.0",
|
|
222
|
+
"prettier": "^2.7.0",
|
|
223
|
+
"supertest": "^6.2.0",
|
|
224
|
+
"webpack": "^5.70.0",
|
|
225
|
+
"webpack-cli": "^4.9.0"
|
|
226
|
+
},
|
|
227
|
+
"engines": {
|
|
228
|
+
"node": ">=16.0.0",
|
|
229
|
+
"npm": ">=8.0.0"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### .gitignore for JavaScript
|
|
235
|
+
```
|
|
236
|
+
# Dependencies
|
|
237
|
+
node_modules/
|
|
238
|
+
npm-debug.log*
|
|
239
|
+
yarn-debug.log*
|
|
240
|
+
yarn-error.log*
|
|
241
|
+
|
|
242
|
+
# Runtime data
|
|
243
|
+
pids
|
|
244
|
+
*.pid
|
|
245
|
+
*.seed
|
|
246
|
+
*.pid.lock
|
|
247
|
+
|
|
248
|
+
# Coverage directory used by tools like istanbul
|
|
249
|
+
coverage/
|
|
250
|
+
*.lcov
|
|
251
|
+
|
|
252
|
+
# Build output
|
|
253
|
+
dist/
|
|
254
|
+
build/
|
|
255
|
+
lib/
|
|
256
|
+
|
|
257
|
+
# Environment variables
|
|
258
|
+
.env
|
|
259
|
+
.env.local
|
|
260
|
+
.env.development.local
|
|
261
|
+
.env.test.local
|
|
262
|
+
.env.production.local
|
|
263
|
+
|
|
264
|
+
# OS generated files
|
|
265
|
+
.DS_Store
|
|
266
|
+
.DS_Store?
|
|
267
|
+
._*
|
|
268
|
+
.Spotlight-V100
|
|
269
|
+
.Trashes
|
|
270
|
+
ehthumbs.db
|
|
271
|
+
Thumbs.db
|
|
272
|
+
|
|
273
|
+
# IDE files
|
|
274
|
+
.vscode/
|
|
275
|
+
.idea/
|
|
276
|
+
*.swp
|
|
277
|
+
*.swo
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### ESLint Configuration (.eslintrc.js)
|
|
281
|
+
```javascript
|
|
282
|
+
module.exports = {
|
|
283
|
+
env: {
|
|
284
|
+
browser: true,
|
|
285
|
+
es2021: true,
|
|
286
|
+
node: true,
|
|
287
|
+
jest: true,
|
|
288
|
+
},
|
|
289
|
+
extends: [
|
|
290
|
+
'airbnb-base',
|
|
291
|
+
],
|
|
292
|
+
parserOptions: {
|
|
293
|
+
ecmaVersion: 'latest',
|
|
294
|
+
sourceType: 'module',
|
|
295
|
+
},
|
|
296
|
+
rules: {
|
|
297
|
+
'no-console': 'warn',
|
|
298
|
+
'no-unused-vars': 'error',
|
|
299
|
+
'prefer-const': 'error',
|
|
300
|
+
'no-var': 'error',
|
|
301
|
+
'object-shorthand': 'error',
|
|
302
|
+
'prefer-arrow-callback': 'error',
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Prettier Configuration (.prettierrc)
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"semi": true,
|
|
311
|
+
"trailingComma": "es5",
|
|
312
|
+
"singleQuote": true,
|
|
313
|
+
"printWidth": 80,
|
|
314
|
+
"tabWidth": 2,
|
|
315
|
+
"useTabs": false
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Jest Configuration (jest.config.js)
|
|
320
|
+
```javascript
|
|
321
|
+
module.exports = {
|
|
322
|
+
testEnvironment: 'node',
|
|
323
|
+
collectCoverageFrom: [
|
|
324
|
+
'src/**/*.js',
|
|
325
|
+
'!src/**/*.test.js',
|
|
326
|
+
],
|
|
327
|
+
coverageDirectory: 'coverage',
|
|
328
|
+
coverageReporters: ['text', 'lcov', 'html'],
|
|
329
|
+
testMatch: [
|
|
330
|
+
'**/test/**/*.js',
|
|
331
|
+
'**/?(*.)+(spec|test).js',
|
|
332
|
+
],
|
|
333
|
+
verbose: true,
|
|
334
|
+
setupFilesAfterEnv: ['<rootDir>/test/setup.js'],
|
|
335
|
+
};
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Testing Strategies
|
|
339
|
+
|
|
340
|
+
### Unit Tests with Jest
|
|
341
|
+
```javascript
|
|
342
|
+
// test/math.test.js
|
|
343
|
+
const { add, multiply } = require('../src/math');
|
|
344
|
+
|
|
345
|
+
describe('Math functions', () => {
|
|
346
|
+
describe('add', () => {
|
|
347
|
+
test('should add two numbers correctly', () => {
|
|
348
|
+
expect(add(2, 3)).toBe(5);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
test('should handle negative numbers', () => {
|
|
352
|
+
expect(add(-1, 1)).toBe(0);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
describe('multiply', () => {
|
|
357
|
+
test('should multiply two numbers correctly', () => {
|
|
358
|
+
expect(multiply(3, 4)).toBe(12);
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Integration Tests
|
|
365
|
+
```javascript
|
|
366
|
+
// test/server.test.js
|
|
367
|
+
const request = require('supertest');
|
|
368
|
+
const app = require('../src/app');
|
|
369
|
+
|
|
370
|
+
describe('API endpoints', () => {
|
|
371
|
+
test('GET /api/users should return users list', async () => {
|
|
372
|
+
const response = await request(app)
|
|
373
|
+
.get('/api/users')
|
|
374
|
+
.expect(200);
|
|
375
|
+
|
|
376
|
+
expect(response.body).toHaveProperty('users');
|
|
377
|
+
expect(Array.isArray(response.body.users)).toBe(true);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test('POST /api/users should create a new user', async () => {
|
|
381
|
+
const newUser = {
|
|
382
|
+
name: 'John Doe',
|
|
383
|
+
email: 'john@example.com',
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const response = await request(app)
|
|
387
|
+
.post('/api/users')
|
|
388
|
+
.send(newUser)
|
|
389
|
+
.expect(201);
|
|
390
|
+
|
|
391
|
+
expect(response.body).toHaveProperty('id');
|
|
392
|
+
expect(response.body.name).toBe(newUser.name);
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Async Testing
|
|
398
|
+
```javascript
|
|
399
|
+
describe('Async operations', () => {
|
|
400
|
+
test('should handle async function', async () => {
|
|
401
|
+
const result = await asyncFunction();
|
|
402
|
+
expect(result).toBe('expected value');
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test('should handle promises', () => {
|
|
406
|
+
return promiseFunction().then(result => {
|
|
407
|
+
expect(result).toBe('expected value');
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
test('should handle rejected promises', async () => {
|
|
412
|
+
await expect(failingAsyncFunction()).rejects.toThrow('Error message');
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## Error Handling Patterns
|
|
418
|
+
|
|
419
|
+
### Express Error Handling
|
|
420
|
+
```javascript
|
|
421
|
+
// Error handling middleware
|
|
422
|
+
const errorHandler = (err, req, res, next) => {
|
|
423
|
+
console.error(err.stack);
|
|
424
|
+
|
|
425
|
+
if (err.name === 'ValidationError') {
|
|
426
|
+
return res.status(400).json({
|
|
427
|
+
error: 'Validation Error',
|
|
428
|
+
message: err.message,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (err.name === 'MongoError' && err.code === 11000) {
|
|
433
|
+
return res.status(400).json({
|
|
434
|
+
error: 'Duplicate Key Error',
|
|
435
|
+
message: 'Resource already exists',
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
res.status(500).json({
|
|
440
|
+
error: 'Internal Server Error',
|
|
441
|
+
message: process.env.NODE_ENV === 'production'
|
|
442
|
+
? 'Something went wrong'
|
|
443
|
+
: err.message,
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
module.exports = errorHandler;
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### Async Error Handling
|
|
451
|
+
```javascript
|
|
452
|
+
// Async wrapper for error handling
|
|
453
|
+
const asyncHandler = (fn) => (req, res, next) => {
|
|
454
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// Usage
|
|
458
|
+
const getUsers = asyncHandler(async (req, res) => {
|
|
459
|
+
const users = await User.find();
|
|
460
|
+
res.json({ users });
|
|
461
|
+
});
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Custom Error Classes
|
|
465
|
+
```javascript
|
|
466
|
+
class AppError extends Error {
|
|
467
|
+
constructor(message, statusCode) {
|
|
468
|
+
super(message);
|
|
469
|
+
this.statusCode = statusCode;
|
|
470
|
+
this.status = `${statusCode}`.startsWith('4') ? 'fail' : 'error';
|
|
471
|
+
this.isOperational = true;
|
|
472
|
+
|
|
473
|
+
Error.captureStackTrace(this, this.constructor);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
class ValidationError extends AppError {
|
|
478
|
+
constructor(message) {
|
|
479
|
+
super(message, 400);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
class NotFoundError extends AppError {
|
|
484
|
+
constructor(message = 'Resource not found') {
|
|
485
|
+
super(message, 404);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
module.exports = { AppError, ValidationError, NotFoundError };
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
## Performance Optimization
|
|
493
|
+
|
|
494
|
+
### Profiling Commands
|
|
495
|
+
```bash
|
|
496
|
+
# Node.js built-in profiler
|
|
497
|
+
node --prof src/index.js
|
|
498
|
+
node --prof-process isolate-*.log > profiling-output.txt
|
|
499
|
+
|
|
500
|
+
# Memory usage
|
|
501
|
+
node --inspect src/index.js
|
|
502
|
+
# Connect Chrome DevTools to chrome://inspect
|
|
503
|
+
|
|
504
|
+
# Performance monitoring
|
|
505
|
+
npm install -g clinic
|
|
506
|
+
clinic doctor -- node src/index.js
|
|
507
|
+
clinic bubbleprof -- node src/index.js
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### Optimization Techniques
|
|
511
|
+
```javascript
|
|
512
|
+
// Use streams for large data processing
|
|
513
|
+
const fs = require('fs');
|
|
514
|
+
const readline = require('readline');
|
|
515
|
+
|
|
516
|
+
const processLargeFile = async (filename) => {
|
|
517
|
+
const fileStream = fs.createReadStream(filename);
|
|
518
|
+
const rl = readline.createInterface({
|
|
519
|
+
input: fileStream,
|
|
520
|
+
crlfDelay: Infinity,
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
for await (const line of rl) {
|
|
524
|
+
// Process line by line
|
|
525
|
+
processLine(line);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// Connection pooling for databases
|
|
530
|
+
const mysql = require('mysql2/promise');
|
|
531
|
+
|
|
532
|
+
const pool = mysql.createPool({
|
|
533
|
+
host: 'localhost',
|
|
534
|
+
user: 'user',
|
|
535
|
+
password: 'password',
|
|
536
|
+
database: 'database',
|
|
537
|
+
waitForConnections: true,
|
|
538
|
+
connectionLimit: 10,
|
|
539
|
+
queueLimit: 0,
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// Caching strategies
|
|
543
|
+
const NodeCache = require('node-cache');
|
|
544
|
+
const cache = new NodeCache({ stdTTL: 600 }); // 10 minutes
|
|
545
|
+
|
|
546
|
+
const getCachedData = (key) => {
|
|
547
|
+
const cached = cache.get(key);
|
|
548
|
+
if (cached) return cached;
|
|
549
|
+
|
|
550
|
+
const data = fetchFromDatabase(key);
|
|
551
|
+
cache.set(key, data);
|
|
552
|
+
return data;
|
|
553
|
+
};
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
## Documentation Standards
|
|
557
|
+
|
|
558
|
+
### JSDoc Comments
|
|
559
|
+
```javascript
|
|
560
|
+
/**
|
|
561
|
+
* Calculates the area of a rectangle.
|
|
562
|
+
* @param {number} width - The width of the rectangle.
|
|
563
|
+
* @param {number} height - The height of the rectangle.
|
|
564
|
+
* @returns {number} The area of the rectangle.
|
|
565
|
+
* @throws {Error} When width or height is negative.
|
|
566
|
+
* @example
|
|
567
|
+
* // Calculate area of a 5x3 rectangle
|
|
568
|
+
* const area = calculateArea(5, 3);
|
|
569
|
+
* console.log(area); // 15
|
|
570
|
+
*/
|
|
571
|
+
function calculateArea(width, height) {
|
|
572
|
+
if (width < 0 || height < 0) {
|
|
573
|
+
throw new Error('Width and height must be positive numbers');
|
|
574
|
+
}
|
|
575
|
+
return width * height;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* User service for managing user operations.
|
|
580
|
+
* @namespace UserService
|
|
581
|
+
*/
|
|
582
|
+
const UserService = {
|
|
583
|
+
/**
|
|
584
|
+
* Creates a new user.
|
|
585
|
+
* @memberof UserService
|
|
586
|
+
* @param {Object} userData - The user data.
|
|
587
|
+
* @param {string} userData.name - The user's name.
|
|
588
|
+
* @param {string} userData.email - The user's email.
|
|
589
|
+
* @returns {Promise<Object>} The created user object.
|
|
590
|
+
*/
|
|
591
|
+
async createUser(userData) {
|
|
592
|
+
// Implementation
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
## Build Configuration
|
|
598
|
+
|
|
599
|
+
### Webpack Configuration (webpack.config.js)
|
|
600
|
+
```javascript
|
|
601
|
+
const path = require('path');
|
|
602
|
+
|
|
603
|
+
module.exports = {
|
|
604
|
+
entry: './src/index.js',
|
|
605
|
+
output: {
|
|
606
|
+
path: path.resolve(__dirname, 'dist'),
|
|
607
|
+
filename: 'bundle.js',
|
|
608
|
+
},
|
|
609
|
+
mode: process.env.NODE_ENV || 'development',
|
|
610
|
+
devtool: 'source-map',
|
|
611
|
+
module: {
|
|
612
|
+
rules: [
|
|
613
|
+
{
|
|
614
|
+
test: /\.js$/,
|
|
615
|
+
exclude: /node_modules/,
|
|
616
|
+
use: {
|
|
617
|
+
loader: 'babel-loader',
|
|
618
|
+
options: {
|
|
619
|
+
presets: ['@babel/preset-env'],
|
|
620
|
+
},
|
|
621
|
+
},
|
|
622
|
+
},
|
|
623
|
+
],
|
|
624
|
+
},
|
|
625
|
+
resolve: {
|
|
626
|
+
extensions: ['.js', '.json'],
|
|
627
|
+
},
|
|
628
|
+
devServer: {
|
|
629
|
+
contentBase: './dist',
|
|
630
|
+
hot: true,
|
|
631
|
+
},
|
|
632
|
+
};
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
### Babel Configuration (.babelrc)
|
|
636
|
+
```json
|
|
637
|
+
{
|
|
638
|
+
"presets": [
|
|
639
|
+
[
|
|
640
|
+
"@babel/preset-env",
|
|
641
|
+
{
|
|
642
|
+
"targets": {
|
|
643
|
+
"node": "16"
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
]
|
|
647
|
+
],
|
|
648
|
+
"plugins": [
|
|
649
|
+
"@babel/plugin-proposal-optional-chaining",
|
|
650
|
+
"@babel/plugin-proposal-nullish-coalescing-operator"
|
|
651
|
+
]
|
|
652
|
+
}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
## CI/CD Configuration
|
|
656
|
+
|
|
657
|
+
### GitHub Actions (.github/workflows/node.yml)
|
|
658
|
+
```yaml
|
|
659
|
+
name: Node.js CI
|
|
660
|
+
|
|
661
|
+
on:
|
|
662
|
+
push:
|
|
663
|
+
branches: [ main, develop ]
|
|
664
|
+
pull_request:
|
|
665
|
+
branches: [ main ]
|
|
666
|
+
|
|
667
|
+
jobs:
|
|
668
|
+
test:
|
|
669
|
+
runs-on: ubuntu-latest
|
|
670
|
+
|
|
671
|
+
strategy:
|
|
672
|
+
matrix:
|
|
673
|
+
node-version: [16.x, 18.x, 20.x]
|
|
674
|
+
|
|
675
|
+
steps:
|
|
676
|
+
- uses: actions/checkout@v3
|
|
677
|
+
|
|
678
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
679
|
+
uses: actions/setup-node@v3
|
|
680
|
+
with:
|
|
681
|
+
node-version: ${{ matrix.node-version }}
|
|
682
|
+
cache: 'npm'
|
|
683
|
+
|
|
684
|
+
- run: npm ci
|
|
685
|
+
- run: npm run lint
|
|
686
|
+
- run: npm run test:coverage
|
|
687
|
+
- run: npm run build
|
|
688
|
+
- run: npm audit
|
|
689
|
+
|
|
690
|
+
- name: Upload coverage to Codecov
|
|
691
|
+
uses: codecov/codecov-action@v3
|
|
692
|
+
with:
|
|
693
|
+
file: ./coverage/lcov.info
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
## Advanced JavaScript Patterns
|
|
697
|
+
|
|
698
|
+
### Module Pattern
|
|
699
|
+
```javascript
|
|
700
|
+
// ES6 Modules
|
|
701
|
+
export const config = {
|
|
702
|
+
apiUrl: process.env.API_URL || 'http://localhost:3000',
|
|
703
|
+
port: process.env.PORT || 3000,
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
export const utils = {
|
|
707
|
+
formatDate: (date) => date.toISOString(),
|
|
708
|
+
validateEmail: (email) => /\S+@\S+\.\S+/.test(email),
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
export default class ApiClient {
|
|
712
|
+
constructor(baseUrl) {
|
|
713
|
+
this.baseUrl = baseUrl;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
async get(endpoint) {
|
|
717
|
+
// Implementation
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
### Async/Await Patterns
|
|
723
|
+
```javascript
|
|
724
|
+
// Parallel execution
|
|
725
|
+
const fetchAllData = async () => {
|
|
726
|
+
try {
|
|
727
|
+
const [users, posts, comments] = await Promise.all([
|
|
728
|
+
fetchUsers(),
|
|
729
|
+
fetchPosts(),
|
|
730
|
+
fetchComments(),
|
|
731
|
+
]);
|
|
732
|
+
|
|
733
|
+
return { users, posts, comments };
|
|
734
|
+
} catch (error) {
|
|
735
|
+
console.error('Error fetching data:', error);
|
|
736
|
+
throw error;
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
// Sequential execution with error handling
|
|
741
|
+
const processDataSequentially = async (items) => {
|
|
742
|
+
const results = [];
|
|
743
|
+
|
|
744
|
+
for (const item of items) {
|
|
745
|
+
try {
|
|
746
|
+
const result = await processItem(item);
|
|
747
|
+
results.push(result);
|
|
748
|
+
} catch (error) {
|
|
749
|
+
console.error(`Error processing item ${item.id}:`, error);
|
|
750
|
+
// Continue with next item or break depending on requirements
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
return results;
|
|
755
|
+
};
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
## Support Resources
|
|
759
|
+
|
|
760
|
+
- **Node.js Documentation**: https://nodejs.org/docs/
|
|
761
|
+
- **NPM Documentation**: https://docs.npmjs.com/
|
|
762
|
+
- **JavaScript MDN**: https://developer.mozilla.org/en-US/docs/Web/JavaScript
|
|
763
|
+
- **Jest Documentation**: https://jestjs.io/docs/
|
|
764
|
+
- **ESLint Documentation**: https://eslint.org/docs/
|
|
765
|
+
- **Express.js Guide**: https://expressjs.com/en/guide/
|
|
766
|
+
|
|
767
|
+
---
|
|
768
|
+
|
|
769
|
+
Remember: **Claude Flow coordinates, Claude Code creates JavaScript!**
|