claude-flow-novice 2.0.4 → 2.0.5
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/dist/src/cli/commands/guidance.js +668 -487
- package/dist/src/cli/commands/index-validate.js +29 -18
- package/dist/src/cli/commands/mcp-troubleshoot.js +282 -230
- package/dist/src/cli/commands/neural-goal-init.js +125 -92
- package/dist/src/cli/commands/swarm-exec.js +393 -317
- package/dist/src/cli/commands/validate-framework.js +1100 -983
- package/dist/src/cli/commands/validate.js +223 -144
- package/dist/src/cli/main.js +1 -1
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +277 -265
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +7 -6
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +356 -373
- package/dist/src/cli/simple-commands/__tests__/task.test.js +7 -6
- package/dist/src/cli/simple-commands/agent.js +193 -157
- package/dist/src/cli/simple-commands/analysis.js +446 -336
- package/dist/src/cli/simple-commands/automation-executor.js +1339 -1095
- package/dist/src/cli/simple-commands/automation.js +469 -481
- package/dist/src/cli/simple-commands/batch-manager.js +313 -261
- package/dist/src/cli/simple-commands/claude-telemetry.js +267 -241
- package/dist/src/cli/simple-commands/claude-track.js +90 -68
- package/dist/src/cli/simple-commands/concurrent-display.js +320 -266
- package/dist/src/cli/simple-commands/config.js +290 -245
- package/dist/src/cli/simple-commands/coordination.js +234 -182
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +615 -812
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +981 -922
- package/dist/src/cli/simple-commands/fix-hook-variables.js +294 -274
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +457 -378
- package/dist/src/cli/simple-commands/github/github-api.js +574 -535
- package/dist/src/cli/simple-commands/github/init.js +303 -276
- package/dist/src/cli/simple-commands/github.js +247 -222
- package/dist/src/cli/simple-commands/goal.js +63 -51
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +278 -208
- package/dist/src/cli/simple-commands/hive-mind/communication.js +696 -601
- package/dist/src/cli/simple-commands/hive-mind/core.js +979 -907
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +655 -406
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1245 -1125
- package/dist/src/cli/simple-commands/hive-mind/memory.js +1090 -854
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +574 -459
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +347 -263
- package/dist/src/cli/simple-commands/hive-mind/queen.js +768 -727
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +1049 -745
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +283 -227
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +217 -174
- package/dist/src/cli/simple-commands/hive-mind.js +2282 -1841
- package/dist/src/cli/simple-commands/hive.js +79 -90
- package/dist/src/cli/simple-commands/hook-safety.js +521 -431
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +254 -203
- package/dist/src/cli/simple-commands/hooks.js +1204 -1064
- package/dist/src/cli/simple-commands/init/agent-copier.js +319 -294
- package/dist/src/cli/simple-commands/init/batch-init.js +562 -496
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +88 -61
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +150 -125
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +49 -42
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +61 -43
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +147 -141
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +44 -31
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +90 -64
- package/dist/src/cli/simple-commands/init/help.js +107 -104
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +528 -509
- package/dist/src/cli/simple-commands/init/index.js +1759 -1510
- package/dist/src/cli/simple-commands/init/performance-monitor.js +317 -234
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +504 -441
- package/dist/src/cli/simple-commands/init/rollback/index.js +364 -289
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +728 -652
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +481 -416
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +448 -369
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +2 -1
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +99 -122
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +37 -32
- package/dist/src/cli/simple-commands/init/sparc-structure.js +62 -55
- package/dist/src/cli/simple-commands/init/template-copier.js +533 -421
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +318 -344
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +218 -173
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +75 -65
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +4 -2
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +230 -187
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +80 -53
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +85 -101
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +330 -283
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +561 -495
- package/dist/src/cli/simple-commands/init/validation/index.js +358 -302
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +359 -308
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +366 -389
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +268 -270
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +447 -427
- package/dist/src/cli/simple-commands/init.js +2 -1
- package/dist/src/cli/simple-commands/mcp-health.js +158 -131
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +634 -533
- package/dist/src/cli/simple-commands/mcp.js +400 -345
- package/dist/src/cli/simple-commands/memory-consolidation.js +537 -426
- package/dist/src/cli/simple-commands/memory.js +311 -247
- package/dist/src/cli/simple-commands/migrate-hooks.js +46 -39
- package/dist/src/cli/simple-commands/monitor.js +363 -294
- package/dist/src/cli/simple-commands/neural.js +65 -51
- package/dist/src/cli/simple-commands/pair-autofix-only.js +662 -538
- package/dist/src/cli/simple-commands/pair-basic.js +656 -528
- package/dist/src/cli/simple-commands/pair-old.js +543 -430
- package/dist/src/cli/simple-commands/pair-working.js +751 -615
- package/dist/src/cli/simple-commands/pair.js +751 -615
- package/dist/src/cli/simple-commands/performance-hooks.js +111 -83
- package/dist/src/cli/simple-commands/performance-metrics.js +433 -348
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +787 -708
- package/dist/src/cli/simple-commands/process-ui.js +254 -230
- package/dist/src/cli/simple-commands/realtime-update-system.js +611 -525
- package/dist/src/cli/simple-commands/sparc/architecture.js +1530 -1704
- package/dist/src/cli/simple-commands/sparc/commands.js +516 -438
- package/dist/src/cli/simple-commands/sparc/completion.js +1481 -1224
- package/dist/src/cli/simple-commands/sparc/coordinator.js +978 -913
- package/dist/src/cli/simple-commands/sparc/index.js +298 -241
- package/dist/src/cli/simple-commands/sparc/phase-base.js +390 -314
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +869 -965
- package/dist/src/cli/simple-commands/sparc/refinement.js +1273 -980
- package/dist/src/cli/simple-commands/sparc/specification.js +645 -559
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +55 -47
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +87 -101
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +493 -465
- package/dist/src/cli/simple-commands/start-ui.js +132 -108
- package/dist/src/cli/simple-commands/start-wrapper.js +268 -240
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +275 -254
- package/dist/src/cli/simple-commands/stream-chain-clean.js +171 -128
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +82 -61
- package/dist/src/cli/simple-commands/stream-chain-real.js +331 -267
- package/dist/src/cli/simple-commands/stream-chain-working.js +263 -211
- package/dist/src/cli/simple-commands/stream-chain.js +318 -260
- package/dist/src/cli/simple-commands/stream-processor.js +315 -290
- package/dist/src/cli/simple-commands/swarm-executor.js +222 -189
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +300 -208
- package/dist/src/cli/simple-commands/swarm-ui.js +703 -623
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +286 -258
- package/dist/src/cli/simple-commands/swarm.js +1082 -887
- package/dist/src/cli/simple-commands/task.js +206 -161
- package/dist/src/cli/simple-commands/timestamp-fix.js +89 -59
- package/dist/src/cli/simple-commands/token-tracker.js +316 -258
- package/dist/src/cli/simple-commands/tool-execution-framework.js +519 -433
- package/dist/src/cli/simple-commands/train-and-stream.js +331 -275
- package/dist/src/cli/simple-commands/training-pipeline.js +725 -619
- package/dist/src/cli/simple-commands/training.js +227 -170
- package/dist/src/cli/simple-commands/verification-hooks.js +284 -261
- package/dist/src/cli/simple-commands/verification-integration.js +417 -389
- package/dist/src/cli/simple-commands/verification-training-integration.js +606 -486
- package/dist/src/cli/simple-commands/verification.js +513 -493
- package/dist/src/cli/simple-commands/web-server.js +836 -766
- package/dist/src/cli/simple-commands/webui-validator.js +124 -106
- package/dist/src/coordination/byzantine-memory-channels.js +25 -1
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +251 -212
- package/dist/src/coordination/event-bus/qe-event-bus.js +748 -608
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +454 -379
- package/dist/src/coordination/iteration-tracker.js +454 -363
- package/dist/src/index.js +384 -35
- package/dist/src/mcp/DEPRECATED.js +60 -46
- package/dist/src/mcp/fixes/mcp-error-fixes.js +134 -115
- package/dist/src/mcp/implementations/agent-tracker.js +128 -114
- package/dist/src/mcp/implementations/daa-tools.js +350 -292
- package/dist/src/mcp/implementations/workflow-tools.js +361 -329
- package/dist/src/mcp/mcp-config-manager.js +1331 -1183
- package/dist/src/mcp/mcp-server-novice-simplified.js +17 -11
- package/dist/src/mcp/mcp-server-novice.js +17 -11
- package/dist/src/mcp/mcp-server-sdk.js +17 -11
- package/dist/src/mcp/mcp-server.js +1484 -1620
- package/dist/src/mcp/ruv-swarm-wrapper.js +239 -209
- package/dist/src/memory/advanced-serializer.js +589 -609
- package/dist/src/memory/enhanced-examples.js +305 -220
- package/dist/src/memory/enhanced-memory.js +336 -295
- package/dist/src/memory/enhanced-session-serializer.js +492 -408
- package/dist/src/memory/fallback-memory-system.js +1021 -900
- package/dist/src/memory/fallback-store.js +131 -93
- package/dist/src/memory/high-performance-serialization.js +730 -592
- package/dist/src/memory/in-memory-store.js +213 -161
- package/dist/src/memory/index.js +157 -123
- package/dist/src/memory/lock-free-structures.js +764 -578
- package/dist/src/memory/memory-mapped-persistence.js +766 -585
- package/dist/src/memory/memory-pressure-manager.js +707 -569
- package/dist/src/memory/migration.js +445 -358
- package/dist/src/memory/shared-memory.js +768 -641
- package/dist/src/memory/sqlite-store.js +325 -245
- package/dist/src/memory/sqlite-wrapper.js +151 -122
- package/dist/src/memory/swarm-memory.js +603 -470
- package/dist/src/memory/test-example.js +134 -126
- package/dist/src/memory/ultra-fast-memory-store.js +821 -622
- package/dist/src/memory/unified-memory-manager.js +437 -356
- package/dist/src/swarm/CodeRefactoringSwarm.js +952 -777
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +400 -332
- package/dist/src/utils/error-handler.js +2 -36
- package/dist/src/utils/github-cli-safe.js +64 -56
- package/dist/src/utils/github-cli-safety-wrapper.js +546 -451
- package/dist/src/utils/npx-isolated-cache.js +119 -104
- package/dist/src/utils/preference-manager.js +652 -622
- package/dist/src/utils/timezone-utils.js +105 -86
- package/dist/src/web/api/apm-routes.js +353 -0
- package/dist/src/web/api/config/api-config.js +184 -0
- package/dist/src/web/api/middleware/auth.js +203 -0
- package/dist/src/web/api/middleware/cache.js +273 -0
- package/dist/src/web/api/middleware/error-handler.js +257 -0
- package/dist/src/web/api/middleware/request-logger.js +215 -0
- package/dist/src/web/api/middleware/validation.js +323 -0
- package/dist/src/web/api/routes/events.js +463 -0
- package/dist/src/web/api/routes/hierarchy.js +300 -0
- package/dist/src/web/api/routes/index.js +12 -0
- package/dist/src/web/api/routes/metrics.js +559 -0
- package/dist/src/web/api/routes/parallel-status.js +359 -0
- package/dist/src/web/api/routes/status.js +448 -0
- package/dist/src/web/api/server.js +462 -0
- package/dist/src/web/dashboard/hooks/useWebSocket.js +383 -0
- package/dist/src/web/dashboard/index.js +85 -0
- package/dist/src/web/dashboard/realtime/CustomSyncManager.js +439 -0
- package/dist/src/web/dashboard/realtime/NativeWebSocketManager.js +323 -0
- package/dist/src/web/dashboard/realtime/PerformanceBenchmark.js +527 -0
- package/dist/src/web/dashboard/realtime/RealtimeCommunicationManager.js +474 -0
- package/dist/src/web/dashboard/realtime/RealtimeServer.js +666 -0
- package/dist/src/web/dashboard/realtime/SSEManager.js +426 -0
- package/dist/src/web/dashboard/types.js +4 -0
- package/dist/src/web/messaging/agent-status-tracker.js +453 -0
- package/dist/src/web/messaging/human-intervention-system.js +305 -0
- package/dist/src/web/messaging/message-filter.js +302 -0
- package/dist/src/web/messaging/swarm-message-router.js +324 -0
- package/dist/src/web/messaging/transparency-logger.js +421 -0
- package/dist/src/web/portal-server.js +460 -0
- package/dist/src/web/server.js +322 -0
- package/dist/src/web/websocket/apm-websocket-handler.js +453 -0
- package/dist/src/web/websocket/websocket-manager.js +780 -0
- package/package.json +5 -3
- package/dist/src/cli/minimal-main.js +0 -22
- package/dist/src/enterprise/analytics-manager.js +0 -1135
- package/dist/src/enterprise/audit-manager.js +0 -1115
- package/dist/src/enterprise/cloud-manager.js +0 -891
- package/dist/src/enterprise/deployment-manager.js +0 -966
- package/dist/src/enterprise/index.js +0 -6
- package/dist/src/enterprise/project-manager.js +0 -584
- package/dist/src/enterprise/security-manager.js +0 -991
- package/dist/src/migration/index.js +0 -92
- package/dist/src/migration/logger.js +0 -121
- package/dist/src/migration/migration-analyzer.js +0 -268
- package/dist/src/migration/migration-runner.js +0 -522
- package/dist/src/migration/migration-validator.js +0 -285
- package/dist/src/migration/progress-reporter.js +0 -150
- package/dist/src/migration/rollback-manager.js +0 -321
- package/dist/src/migration/tests/migration-system.test.js +0 -7
- package/dist/src/migration/types.js +0 -3
- package/dist/src/swarm/__tests__/integration.test.js +0 -227
- package/dist/src/swarm/__tests__/prompt-copier.test.js +0 -344
- package/dist/src/swarm/advanced-orchestrator.js +0 -1095
- package/dist/src/swarm/claude-code-interface.js +0 -961
- package/dist/src/swarm/claude-flow-executor.js +0 -229
- package/dist/src/swarm/consensus-coordinator.js +0 -475
- package/dist/src/swarm/coordinator.js +0 -2993
- package/dist/src/swarm/direct-executor.js +0 -1180
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +0 -691
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +0 -998
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +0 -1197
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +0 -772
- package/dist/src/swarm/error-recovery/resilience-architecture.js +0 -714
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +0 -1319
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +0 -808
- package/dist/src/swarm/executor-v2.js +0 -322
- package/dist/src/swarm/executor.js +0 -815
- package/dist/src/swarm/hive-mind-integration.js +0 -703
- package/dist/src/swarm/index.js +0 -41
- package/dist/src/swarm/json-output-aggregator.js +0 -267
- package/dist/src/swarm/large-scale-coordinator.js +0 -542
- package/dist/src/swarm/mcp-integration-wrapper.js +0 -628
- package/dist/src/swarm/memory.js +0 -1117
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +0 -348
- package/dist/src/swarm/optimizations/async-file-manager.js +0 -285
- package/dist/src/swarm/optimizations/circular-buffer.js +0 -162
- package/dist/src/swarm/optimizations/connection-pool.js +0 -244
- package/dist/src/swarm/optimizations/index.js +0 -28
- package/dist/src/swarm/optimizations/optimized-executor.js +0 -320
- package/dist/src/swarm/optimizations/ttl-map.js +0 -234
- package/dist/src/swarm/prompt-cli.js +0 -200
- package/dist/src/swarm/prompt-copier-enhanced.js +0 -202
- package/dist/src/swarm/prompt-copier.js +0 -381
- package/dist/src/swarm/prompt-manager.js +0 -295
- package/dist/src/swarm/prompt-utils.js +0 -310
- package/dist/src/swarm/result-aggregator.js +0 -718
- package/dist/src/swarm/sparc-executor.js +0 -1568
- package/dist/src/swarm/strategies/auto.js +0 -758
- package/dist/src/swarm/strategies/base.js +0 -128
- package/dist/src/swarm/strategies/research.js +0 -914
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +0 -2
- package/dist/src/swarm/types.js +0 -52
- package/dist/src/swarm/workers/copy-worker.js +0 -56
- package/dist/src/validators/epic-config-schema.js +0 -214
- package/dist/src/validators/index.js +0 -10
- package/dist/src/validators/swarm-init-validator.js +0 -259
- package/dist/src/validators/todowrite-batching-validator.js +0 -215
- package/dist/src/validators/todowrite-integration.js +0 -187
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols.js +0 -23
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +0 -57
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +0 -401
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +0 -181
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js +0 -44
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +0 -157
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/edit.js +0 -71
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/editorState/browser/editorState.js +0 -112
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findController.js +0 -990
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findDecorations.js +0 -296
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findModel.js +0 -488
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +0 -138
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findState.js +0 -243
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findWidget.js +0 -1177
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/folding.js +0 -1093
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +0 -133
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingModel.js +0 -538
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingRanges.js +0 -351
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +0 -49
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/format.js +0 -360
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formatActions.js +0 -263
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formattingEdit.js +0 -54
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.js +0 -149
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/hover/browser/contentHover.js +0 -874
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commandIds.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commands.js +0 -199
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/linesOperations/browser/copyLinesCommand.js +0 -70
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +0 -26
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +0 -153
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +0 -33
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/semanticTokens/browser/documentSemanticTokens.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/smartSelect/browser/bracketSelections.js +0 -146
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/suggest/browser/completionModel.js +0 -224
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +0 -119
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/edcore.main.js +0 -14
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.all.js +0 -63
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.api.js +0 -55
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.main.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.worker.js +0 -25
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/standalone/browser/colorizer.js +0 -118
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/css.worker.js +0 -36869
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/cssMode.js +0 -2035
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cameligo/cameligo.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/clojure/clojure.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/coffee/coffee.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cpp/cpp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csharp/csharp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csp/csp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/css/css.js +0 -12
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cypher/cypher.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dart/dart.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dockerfile/dockerfile.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/ecl/ecl.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/elixir/elixir.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/flow9/flow9.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.js +0 -745
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.de.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.es.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.fr.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.it.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ja.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ko.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ru.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-cn.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-tw.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssMode.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssWorker.js +0 -81
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/cli.js +0 -64
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/example.js +0 -36
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/index.js +0 -205
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/test.js +0 -260
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.js +0 -35
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.native.js +0 -26
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.js +0 -45
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/nanoid.js +0 -1
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/non-secure/index.js +0 -21
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/url-alphabet/index.js +0 -3
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/bin/nodemon.js +0 -16
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/parse.js +0 -230
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/command.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/defaults.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/exec.js +0 -234
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/index.js +0 -93
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/load.js +0 -225
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/help/index.js +0 -27
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/index.js +0 -1
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/index.js +0 -4
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/match.js +0 -287
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/run.js +0 -562
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/signals.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/watch.js +0 -244
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/nodemon.js +0 -317
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/add.js +0 -89
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/index.js +0 -53
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/parse.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/spawn.js +0 -74
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/bus.js +0 -44
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/clone.js +0 -40
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/colour.js +0 -26
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/index.js +0 -103
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/log.js +0 -82
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/merge.js +0 -47
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/version.js +0 -100
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/brace-expansion/index.js +0 -201
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/has-flag/index.js +0 -8
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/minimatch/minimatch.js +0 -947
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/browser.js +0 -5
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/index.js +0 -131
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/bin/pidtree.js +0 -128
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/bin.js +0 -61
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/get.js +0 -45
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/pidtree.js +0 -104
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/ps.js +0 -47
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/wmic.js +0 -49
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/doc.js +0 -1270
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/acorn.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/angular.js +0 -2
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/babel.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/estree.js +0 -36
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/flow.js +0 -19
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/glimmer.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/graphql.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/html.js +0 -22
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/markdown.js +0 -63
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/meriyah.js +0 -4
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/postcss.js +0 -54
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/typescript.js +0 -20
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/yaml.js +0 -160
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/standalone.js +0 -34
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/bin/react-scripts.js +0 -58
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/env.js +0 -112
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/getHttpsConfig.js +0 -74
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/babelTransform.js +0 -37
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/cssTransform.js +0 -22
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/fileTransform.js +0 -40
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/modules.js +0 -142
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/paths.js +0 -153
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack.config.js +0 -796
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpackDevServer.config.js +0 -135
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/build.js +0 -225
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/eject.js +0 -340
|
@@ -1,269 +1,351 @@
|
|
|
1
1
|
// SPARC Refinement Phase
|
|
2
2
|
// Implement with TDD (Red-Green-Refactor) and optimization
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { SparcPhase } from './phase-base.js';
|
|
5
|
+
|
|
4
6
|
export class SparcRefinement extends SparcPhase {
|
|
5
|
-
|
|
7
|
+
constructor(taskDescription, options) {
|
|
8
|
+
super('refinement', taskDescription, options);
|
|
9
|
+
this.tddCycles = [];
|
|
10
|
+
this.implementations = [];
|
|
11
|
+
this.optimizations = [];
|
|
12
|
+
this.testResults = null;
|
|
13
|
+
this.codeQuality = null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
6
17
|
* Execute refinement phase
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
18
|
+
*/
|
|
19
|
+
async execute() {
|
|
20
|
+
console.log('🔧 Starting Refinement Phase');
|
|
21
|
+
|
|
22
|
+
await this.initializePhase();
|
|
23
|
+
|
|
24
|
+
const result = {
|
|
25
|
+
tddCycles: [],
|
|
26
|
+
implementations: [],
|
|
27
|
+
testResults: null,
|
|
28
|
+
codeQuality: {},
|
|
29
|
+
optimizations: [],
|
|
30
|
+
performance: {},
|
|
31
|
+
security: {},
|
|
32
|
+
documentation: {},
|
|
33
|
+
refactoring: {},
|
|
34
|
+
validation: {},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// Load previous phases
|
|
39
|
+
const specification = await this.retrieveFromMemory('specification_complete');
|
|
40
|
+
const pseudocode = await this.retrieveFromMemory('pseudocode_complete');
|
|
41
|
+
const architecture = await this.retrieveFromMemory('architecture_complete');
|
|
42
|
+
|
|
43
|
+
if (!specification || !pseudocode || !architecture) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
'Specification, Pseudocode, and Architecture phases must be completed first',
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Execute TDD cycles
|
|
50
|
+
result.tddCycles = await this.executeTddCycles(specification, pseudocode, architecture);
|
|
51
|
+
|
|
52
|
+
// Generate implementations
|
|
53
|
+
result.implementations = await this.generateImplementations(architecture);
|
|
54
|
+
|
|
55
|
+
// Run tests and collect results
|
|
56
|
+
result.testResults = await this.runTests(result.tddCycles);
|
|
57
|
+
|
|
58
|
+
// Analyze code quality
|
|
59
|
+
result.codeQuality = await this.analyzeCodeQuality(result.implementations);
|
|
60
|
+
|
|
61
|
+
// Apply optimizations
|
|
62
|
+
result.optimizations = await this.applyOptimizations(
|
|
63
|
+
result.implementations,
|
|
64
|
+
result.codeQuality,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Analyze performance
|
|
68
|
+
result.performance = await this.analyzePerformance(result.implementations);
|
|
69
|
+
|
|
70
|
+
// Analyze security
|
|
71
|
+
result.security = await this.analyzeSecurity(result.implementations);
|
|
72
|
+
|
|
73
|
+
// DISABLED: Documentation generation disabled to reduce excessive doc creation
|
|
74
|
+
// result.documentation = await this.generateDocumentation(result.implementations);
|
|
75
|
+
result.documentation = { api: null, components: [], deployment: null, userGuide: null, developerGuide: null };
|
|
76
|
+
|
|
77
|
+
// Apply refactoring
|
|
78
|
+
result.refactoring = await this.applyRefactoring(result.implementations, result.codeQuality);
|
|
79
|
+
|
|
80
|
+
// Final validation
|
|
81
|
+
result.validation = await this.performFinalValidation(result);
|
|
82
|
+
|
|
83
|
+
// Generate refinement document
|
|
84
|
+
await this.generateRefinementDocument(result);
|
|
85
|
+
|
|
86
|
+
// Store in memory
|
|
87
|
+
await this.storeInMemory('refinement_complete', result);
|
|
88
|
+
|
|
89
|
+
console.log('✅ Refinement phase completed');
|
|
90
|
+
return result;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error('❌ Refinement phase failed:', error.message);
|
|
93
|
+
throw error;
|
|
67
94
|
}
|
|
68
|
-
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
69
98
|
* Execute TDD cycles (Red-Green-Refactor)
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
*/
|
|
100
|
+
async executeTddCycles(specification, pseudocode, architecture) {
|
|
101
|
+
const cycles = [];
|
|
102
|
+
const requirements = specification.requirements || [];
|
|
103
|
+
|
|
104
|
+
for (const [index, requirement] of requirements.entries()) {
|
|
105
|
+
console.log(`🔄 TDD Cycle ${index + 1}: ${requirement}`);
|
|
106
|
+
|
|
107
|
+
const cycle = {
|
|
108
|
+
id: `tdd-cycle-${index + 1}`,
|
|
109
|
+
requirement: requirement,
|
|
110
|
+
redPhase: null,
|
|
111
|
+
greenPhase: null,
|
|
112
|
+
refactorPhase: null,
|
|
113
|
+
duration: 0,
|
|
114
|
+
success: false,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const startTime = Date.now();
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
// RED: Write failing test
|
|
121
|
+
cycle.redPhase = await this.executeRedPhase(requirement, architecture);
|
|
122
|
+
|
|
123
|
+
// GREEN: Make test pass with minimal implementation
|
|
124
|
+
cycle.greenPhase = await this.executeGreenPhase(cycle.redPhase, architecture);
|
|
125
|
+
|
|
126
|
+
// REFACTOR: Improve code while keeping tests green
|
|
127
|
+
cycle.refactorPhase = await this.executeRefactorPhase(cycle.greenPhase, architecture);
|
|
128
|
+
|
|
129
|
+
cycle.success = true;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
cycle.error = error.message;
|
|
132
|
+
cycle.success = false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
cycle.duration = Date.now() - startTime;
|
|
136
|
+
cycles.push(cycle);
|
|
101
137
|
}
|
|
102
|
-
|
|
138
|
+
|
|
139
|
+
return cycles;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
103
143
|
* Execute RED phase (write failing test)
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
144
|
+
*/
|
|
145
|
+
async executeRedPhase(requirement, architecture) {
|
|
146
|
+
const redPhase = {
|
|
147
|
+
phase: 'red',
|
|
148
|
+
requirement: requirement,
|
|
149
|
+
tests: [],
|
|
150
|
+
status: 'completed',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Generate test cases for the requirement
|
|
154
|
+
const testCases = this.generateTestCases(requirement, architecture);
|
|
155
|
+
|
|
156
|
+
for (const testCase of testCases) {
|
|
157
|
+
const test = {
|
|
158
|
+
name: testCase.name,
|
|
159
|
+
description: testCase.description,
|
|
160
|
+
code: this.generateTestCode(testCase),
|
|
161
|
+
expected: 'fail',
|
|
162
|
+
actual: 'fail',
|
|
163
|
+
passed: false,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
redPhase.tests.push(test);
|
|
126
167
|
}
|
|
127
|
-
|
|
168
|
+
|
|
169
|
+
console.log(` 🔴 RED: Created ${redPhase.tests.length} failing tests`);
|
|
170
|
+
return redPhase;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
128
174
|
* Execute GREEN phase (make tests pass)
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
175
|
+
*/
|
|
176
|
+
async executeGreenPhase(redPhase, architecture) {
|
|
177
|
+
const greenPhase = {
|
|
178
|
+
phase: 'green',
|
|
179
|
+
implementations: [],
|
|
180
|
+
testResults: [],
|
|
181
|
+
status: 'completed',
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Generate minimal implementation for each test
|
|
185
|
+
for (const test of redPhase.tests) {
|
|
186
|
+
const implementation = this.generateMinimalImplementation(test, architecture);
|
|
187
|
+
greenPhase.implementations.push(implementation);
|
|
188
|
+
|
|
189
|
+
// Simulate test run
|
|
190
|
+
const testResult = {
|
|
191
|
+
testName: test.name,
|
|
192
|
+
passed: true,
|
|
193
|
+
executionTime: Math.random() * 100 + 50, // 50-150ms
|
|
194
|
+
assertions: this.generateAssertions(test),
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
greenPhase.testResults.push(testResult);
|
|
151
198
|
}
|
|
152
|
-
|
|
199
|
+
|
|
200
|
+
console.log(
|
|
201
|
+
` 🟢 GREEN: Made ${greenPhase.testResults.filter((t) => t.passed).length} tests pass`,
|
|
202
|
+
);
|
|
203
|
+
return greenPhase;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
153
207
|
* Execute REFACTOR phase (improve code)
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const newTestResult = {
|
|
172
|
-
...testResult,
|
|
173
|
-
passed: true,
|
|
174
|
-
executionTime: testResult.executionTime * (0.8 + Math.random() * 0.4)
|
|
175
|
-
};
|
|
176
|
-
refactorPhase.testResults.push(newTestResult);
|
|
177
|
-
}
|
|
178
|
-
console.log(` 🔵 REFACTOR: Applied ${refactorPhase.refactorings.length} refactoring techniques`);
|
|
179
|
-
return refactorPhase;
|
|
208
|
+
*/
|
|
209
|
+
async executeRefactorPhase(greenPhase, architecture) {
|
|
210
|
+
const refactorPhase = {
|
|
211
|
+
phase: 'refactor',
|
|
212
|
+
refactorings: [],
|
|
213
|
+
improvedImplementations: [],
|
|
214
|
+
testResults: [],
|
|
215
|
+
status: 'completed',
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Apply refactoring to each implementation
|
|
219
|
+
for (const implementation of greenPhase.implementations) {
|
|
220
|
+
const refactoring = this.applyRefactoringTechniques(implementation);
|
|
221
|
+
refactorPhase.refactorings.push(refactoring);
|
|
222
|
+
|
|
223
|
+
const improvedImplementation = this.generateRefactoredCode(implementation, refactoring);
|
|
224
|
+
refactorPhase.improvedImplementations.push(improvedImplementation);
|
|
180
225
|
}
|
|
181
|
-
|
|
226
|
+
|
|
227
|
+
// Re-run tests to ensure they still pass
|
|
228
|
+
for (const testResult of greenPhase.testResults) {
|
|
229
|
+
const newTestResult = {
|
|
230
|
+
...testResult,
|
|
231
|
+
passed: true, // Assume refactoring maintains functionality
|
|
232
|
+
executionTime: testResult.executionTime * (0.8 + Math.random() * 0.4), // Slight performance variation
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
refactorPhase.testResults.push(newTestResult);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
console.log(
|
|
239
|
+
` 🔵 REFACTOR: Applied ${refactorPhase.refactorings.length} refactoring techniques`,
|
|
240
|
+
);
|
|
241
|
+
return refactorPhase;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
182
245
|
* Generate test cases for requirement
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
246
|
+
*/
|
|
247
|
+
generateTestCases(requirement, architecture) {
|
|
248
|
+
const testCases = [];
|
|
249
|
+
const reqLower = requirement.toLowerCase();
|
|
250
|
+
|
|
251
|
+
// Happy path test
|
|
252
|
+
testCases.push({
|
|
253
|
+
name: `test_${this.camelCase(requirement)}_success`,
|
|
254
|
+
description: `Test successful execution of ${requirement}`,
|
|
255
|
+
type: 'positive',
|
|
256
|
+
scenario: 'valid input',
|
|
257
|
+
expected: 'success',
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// Error cases
|
|
261
|
+
testCases.push({
|
|
262
|
+
name: `test_${this.camelCase(requirement)}_invalid_input`,
|
|
263
|
+
description: `Test ${requirement} with invalid input`,
|
|
264
|
+
type: 'negative',
|
|
265
|
+
scenario: 'invalid input',
|
|
266
|
+
expected: 'error',
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Edge cases
|
|
270
|
+
if (reqLower.includes('data') || reqLower.includes('validate')) {
|
|
271
|
+
testCases.push({
|
|
272
|
+
name: `test_${this.camelCase(requirement)}_empty_data`,
|
|
273
|
+
description: `Test ${requirement} with empty data`,
|
|
274
|
+
type: 'edge',
|
|
275
|
+
scenario: 'empty data',
|
|
276
|
+
expected: 'handled gracefully',
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Performance test
|
|
281
|
+
if (reqLower.includes('api') || reqLower.includes('performance')) {
|
|
282
|
+
testCases.push({
|
|
283
|
+
name: `test_${this.camelCase(requirement)}_performance`,
|
|
284
|
+
description: `Test ${requirement} performance under load`,
|
|
285
|
+
type: 'performance',
|
|
286
|
+
scenario: 'high load',
|
|
287
|
+
expected: 'acceptable response time',
|
|
288
|
+
});
|
|
223
289
|
}
|
|
224
|
-
|
|
290
|
+
|
|
291
|
+
return testCases;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
225
295
|
* Generate test code
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
|
-
|
|
296
|
+
*/
|
|
297
|
+
generateTestCode(testCase) {
|
|
298
|
+
const functionName = this.extractFunctionName(testCase.name);
|
|
299
|
+
|
|
300
|
+
return `describe('${testCase.description}', () => {
|
|
229
301
|
test('${testCase.name}', async () => {
|
|
230
302
|
// Arrange
|
|
231
303
|
const input = ${this.generateTestInput(testCase)};
|
|
232
304
|
const expected = ${this.generateExpectedOutput(testCase)};
|
|
233
305
|
|
|
234
306
|
// Act
|
|
235
|
-
${
|
|
307
|
+
${
|
|
308
|
+
testCase.type === 'negative'
|
|
309
|
+
? `
|
|
236
310
|
const action = () => ${functionName}(input);
|
|
237
311
|
|
|
238
312
|
// Assert
|
|
239
|
-
expect(action).toThrow();`
|
|
313
|
+
expect(action).toThrow();`
|
|
314
|
+
: `
|
|
240
315
|
const result = await ${functionName}(input);
|
|
241
316
|
|
|
242
317
|
// Assert
|
|
243
|
-
expect(result).toEqual(expected);`
|
|
318
|
+
expect(result).toEqual(expected);`
|
|
319
|
+
}
|
|
244
320
|
});
|
|
245
321
|
});`;
|
|
246
|
-
|
|
247
|
-
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
248
325
|
* Generate minimal implementation
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
326
|
+
*/
|
|
327
|
+
generateMinimalImplementation(test, architecture) {
|
|
328
|
+
const functionName = this.extractFunctionName(test.name);
|
|
329
|
+
const component = this.findRelevantComponent(test, architecture);
|
|
330
|
+
|
|
331
|
+
return {
|
|
332
|
+
name: functionName,
|
|
333
|
+
component: component ? component.name : 'DefaultComponent',
|
|
334
|
+
code: this.generateMinimalCode(test, functionName),
|
|
335
|
+
dependencies: component ? component.dependencies : [],
|
|
336
|
+
complexity: 'low',
|
|
337
|
+
testCoverage: 100,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
262
342
|
* Generate minimal code
|
|
263
|
-
*/
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
343
|
+
*/
|
|
344
|
+
generateMinimalCode(test, functionName) {
|
|
345
|
+
const testType = test.expected;
|
|
346
|
+
|
|
347
|
+
if (testType === 'fail' || test.type === 'negative') {
|
|
348
|
+
return `async function ${functionName}(input) {
|
|
267
349
|
// Minimal implementation to make test pass
|
|
268
350
|
if (!input || typeof input !== 'object') {
|
|
269
351
|
throw new Error('Invalid input');
|
|
@@ -272,8 +354,8 @@ export class SparcRefinement extends SparcPhase {
|
|
|
272
354
|
// TODO: Implement actual logic
|
|
273
355
|
return { success: false, message: 'Not implemented' };
|
|
274
356
|
}`;
|
|
275
|
-
|
|
276
|
-
|
|
357
|
+
} else {
|
|
358
|
+
return `async function ${functionName}(input) {
|
|
277
359
|
// Minimal implementation to make test pass
|
|
278
360
|
if (!input) {
|
|
279
361
|
throw new Error('Input required');
|
|
@@ -302,63 +384,75 @@ function processInput(input) {
|
|
|
302
384
|
// Minimal processing
|
|
303
385
|
return { processed: true, input };
|
|
304
386
|
}`;
|
|
305
|
-
}
|
|
306
387
|
}
|
|
307
|
-
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
308
391
|
* Apply refactoring techniques
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
refactorings.push({
|
|
321
|
-
technique: 'Extract Variable',
|
|
322
|
-
reason: 'Improve readability',
|
|
323
|
-
description: 'Extract complex expressions into well-named variables'
|
|
324
|
-
});
|
|
325
|
-
// Remove code duplication
|
|
326
|
-
refactorings.push({
|
|
327
|
-
technique: 'Remove Duplication',
|
|
328
|
-
reason: 'DRY principle',
|
|
329
|
-
description: 'Extract common code into reusable functions'
|
|
330
|
-
});
|
|
331
|
-
// Improve naming
|
|
332
|
-
refactorings.push({
|
|
333
|
-
technique: 'Rename Variables',
|
|
334
|
-
reason: 'Clarity',
|
|
335
|
-
description: 'Use more descriptive variable and function names'
|
|
336
|
-
});
|
|
337
|
-
// Add error handling
|
|
338
|
-
refactorings.push({
|
|
339
|
-
technique: 'Improve Error Handling',
|
|
340
|
-
reason: 'Robustness',
|
|
341
|
-
description: 'Add comprehensive error handling and logging'
|
|
342
|
-
});
|
|
343
|
-
return refactorings;
|
|
392
|
+
*/
|
|
393
|
+
applyRefactoringTechniques(implementation) {
|
|
394
|
+
const refactorings = [];
|
|
395
|
+
|
|
396
|
+
// Extract method refactoring
|
|
397
|
+
if (implementation.code.length > 500) {
|
|
398
|
+
refactorings.push({
|
|
399
|
+
technique: 'Extract Method',
|
|
400
|
+
reason: 'Method too long',
|
|
401
|
+
description: 'Break down long method into smaller, focused methods',
|
|
402
|
+
});
|
|
344
403
|
}
|
|
345
|
-
|
|
404
|
+
|
|
405
|
+
// Extract variable refactoring
|
|
406
|
+
refactorings.push({
|
|
407
|
+
technique: 'Extract Variable',
|
|
408
|
+
reason: 'Improve readability',
|
|
409
|
+
description: 'Extract complex expressions into well-named variables',
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// Remove code duplication
|
|
413
|
+
refactorings.push({
|
|
414
|
+
technique: 'Remove Duplication',
|
|
415
|
+
reason: 'DRY principle',
|
|
416
|
+
description: 'Extract common code into reusable functions',
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// Improve naming
|
|
420
|
+
refactorings.push({
|
|
421
|
+
technique: 'Rename Variables',
|
|
422
|
+
reason: 'Clarity',
|
|
423
|
+
description: 'Use more descriptive variable and function names',
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// Add error handling
|
|
427
|
+
refactorings.push({
|
|
428
|
+
technique: 'Improve Error Handling',
|
|
429
|
+
reason: 'Robustness',
|
|
430
|
+
description: 'Add comprehensive error handling and logging',
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
return refactorings;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
346
437
|
* Generate refactored code
|
|
347
|
-
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
438
|
+
*/
|
|
439
|
+
generateRefactoredCode(implementation, refactoring) {
|
|
440
|
+
// This would apply the refactoring techniques to generate improved code
|
|
441
|
+
return {
|
|
442
|
+
...implementation,
|
|
443
|
+
code: this.improveCode(implementation.code, refactoring),
|
|
444
|
+
complexity: this.reduceComplexity(implementation.complexity),
|
|
445
|
+
maintainability: 'improved',
|
|
446
|
+
readability: 'improved',
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
358
451
|
* Improve code based on refactoring
|
|
359
|
-
*/
|
|
360
|
-
|
|
361
|
-
|
|
452
|
+
*/
|
|
453
|
+
improveCode(originalCode, refactoring) {
|
|
454
|
+
// Simulate code improvement
|
|
455
|
+
return `// Refactored code with improvements
|
|
362
456
|
${originalCode}
|
|
363
457
|
|
|
364
458
|
// Additional helper functions
|
|
@@ -379,53 +473,67 @@ const ERROR_MESSAGES = {
|
|
|
379
473
|
PROCESSING_FAILED: 'Processing operation failed',
|
|
380
474
|
TIMEOUT: 'Operation timed out'
|
|
381
475
|
};`;
|
|
382
|
-
|
|
383
|
-
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
384
479
|
* Generate implementations from architecture
|
|
385
|
-
*/
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
480
|
+
*/
|
|
481
|
+
async generateImplementations(architecture) {
|
|
482
|
+
const implementations = [];
|
|
483
|
+
|
|
484
|
+
for (const component of architecture.components) {
|
|
485
|
+
const implementation = {
|
|
486
|
+
component: component.name,
|
|
487
|
+
type: component.type,
|
|
488
|
+
files: [],
|
|
489
|
+
dependencies: component.dependencies,
|
|
490
|
+
interfaces: component.interfaces,
|
|
491
|
+
patterns: component.patterns,
|
|
492
|
+
size: 0,
|
|
493
|
+
complexity: component.complexity,
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
// Generate main implementation file
|
|
497
|
+
const mainFile = this.generateMainImplementationFile(component);
|
|
498
|
+
implementation.files.push(mainFile);
|
|
499
|
+
|
|
500
|
+
// Generate test file
|
|
501
|
+
const testFile = this.generateTestFile(component);
|
|
502
|
+
implementation.files.push(testFile);
|
|
503
|
+
|
|
504
|
+
// Generate interface file if needed
|
|
505
|
+
if (component.interfaces.length > 0) {
|
|
506
|
+
const interfaceFile = this.generateInterfaceFile(component);
|
|
507
|
+
implementation.files.push(interfaceFile);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Calculate total size
|
|
511
|
+
implementation.size = implementation.files.reduce((total, file) => total + file.size, 0);
|
|
512
|
+
|
|
513
|
+
implementations.push(implementation);
|
|
414
514
|
}
|
|
415
|
-
|
|
515
|
+
|
|
516
|
+
return implementations;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
416
520
|
* Generate main implementation file
|
|
417
|
-
*/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
521
|
+
*/
|
|
522
|
+
generateMainImplementationFile(component) {
|
|
523
|
+
const className = component.name;
|
|
524
|
+
const dependencies = component.dependencies
|
|
525
|
+
.map((dep) => `import { ${dep} } from './${dep}';`)
|
|
526
|
+
.join('\n');
|
|
527
|
+
|
|
528
|
+
const code = `${dependencies}
|
|
421
529
|
|
|
422
530
|
/**
|
|
423
531
|
* ${component.name} - ${component.responsibility}
|
|
424
532
|
* Patterns: ${component.patterns.join(', ')}
|
|
425
533
|
*/
|
|
426
534
|
export class ${className} {
|
|
427
|
-
constructor(${component.dependencies.map((dep)=>dep.toLowerCase()).join(', ')}) {
|
|
428
|
-
${component.dependencies.map((dep)
|
|
535
|
+
constructor(${component.dependencies.map((dep) => dep.toLowerCase()).join(', ')}) {
|
|
536
|
+
${component.dependencies.map((dep) => `this.${dep.toLowerCase()} = ${dep.toLowerCase()};`).join('\n ')}
|
|
429
537
|
this.initialized = false;
|
|
430
538
|
this.startTime = Date.now();
|
|
431
539
|
}
|
|
@@ -436,7 +544,7 @@ export class ${className} {
|
|
|
436
544
|
}
|
|
437
545
|
|
|
438
546
|
// Initialize dependencies
|
|
439
|
-
${component.dependencies.map((dep)
|
|
547
|
+
${component.dependencies.map((dep) => `await this.${dep.toLowerCase()}.initialize();`).join('\n ')}
|
|
440
548
|
|
|
441
549
|
this.initialized = true;
|
|
442
550
|
console.log('${className} initialized successfully');
|
|
@@ -484,7 +592,7 @@ export class ${className} {
|
|
|
484
592
|
|
|
485
593
|
async cleanup() {
|
|
486
594
|
// Cleanup resources
|
|
487
|
-
${component.dependencies.map((dep)
|
|
595
|
+
${component.dependencies.map((dep) => `await this.${dep.toLowerCase()}.cleanup();`).join('\n ')}
|
|
488
596
|
|
|
489
597
|
this.initialized = false;
|
|
490
598
|
console.log('${className} cleanup completed');
|
|
@@ -495,55 +603,65 @@ export class ${className} {
|
|
|
495
603
|
component: '${className}',
|
|
496
604
|
initialized: this.initialized,
|
|
497
605
|
uptime: Date.now() - this.startTime,
|
|
498
|
-
dependencies: [${component.dependencies.map((dep)
|
|
606
|
+
dependencies: [${component.dependencies.map((dep) => `'${dep}'`).join(', ')}]
|
|
499
607
|
};
|
|
500
608
|
}
|
|
501
609
|
}
|
|
502
610
|
|
|
503
611
|
export default ${className};`;
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
612
|
+
|
|
613
|
+
return {
|
|
614
|
+
name: `${className}.js`,
|
|
615
|
+
path: `src/${component.type}/${className}.js`,
|
|
616
|
+
type: 'implementation',
|
|
617
|
+
size: code.length,
|
|
618
|
+
lines: code.split('\n').length,
|
|
619
|
+
code: code,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
514
624
|
* Generate component-specific validation
|
|
515
|
-
*/
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
625
|
+
*/
|
|
626
|
+
generateComponentValidation(component) {
|
|
627
|
+
const compType = component.type.toLowerCase();
|
|
628
|
+
|
|
629
|
+
switch (compType) {
|
|
630
|
+
case 'controller':
|
|
631
|
+
return `// Validate HTTP request structure
|
|
520
632
|
if (!input.method || !input.path) {
|
|
521
633
|
throw new Error('HTTP method and path required');
|
|
522
634
|
}`;
|
|
523
|
-
|
|
524
|
-
|
|
635
|
+
|
|
636
|
+
case 'service':
|
|
637
|
+
return `// Validate service input
|
|
525
638
|
if (!input.data) {
|
|
526
639
|
throw new Error('Service data required');
|
|
527
640
|
}`;
|
|
528
|
-
|
|
529
|
-
|
|
641
|
+
|
|
642
|
+
case 'repository':
|
|
643
|
+
return `// Validate data operations
|
|
530
644
|
if (!input.operation || !input.entity) {
|
|
531
645
|
throw new Error('Operation and entity required');
|
|
532
646
|
}`;
|
|
533
|
-
|
|
534
|
-
|
|
647
|
+
|
|
648
|
+
default:
|
|
649
|
+
return `// Generic validation
|
|
535
650
|
if (Object.keys(input).length === 0) {
|
|
536
651
|
throw new Error('Non-empty input required');
|
|
537
652
|
}`;
|
|
538
|
-
}
|
|
539
653
|
}
|
|
540
|
-
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
541
657
|
* Generate component-specific logic
|
|
542
|
-
*/
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
658
|
+
*/
|
|
659
|
+
generateComponentLogic(component) {
|
|
660
|
+
const compType = component.type.toLowerCase();
|
|
661
|
+
|
|
662
|
+
switch (compType) {
|
|
663
|
+
case 'controller':
|
|
664
|
+
return `// Handle HTTP request
|
|
547
665
|
const { method, path, body, query } = input;
|
|
548
666
|
|
|
549
667
|
// Route to appropriate handler
|
|
@@ -555,8 +673,9 @@ export default ${className};`;
|
|
|
555
673
|
data: result,
|
|
556
674
|
timestamp: new Date().toISOString()
|
|
557
675
|
};`;
|
|
558
|
-
|
|
559
|
-
|
|
676
|
+
|
|
677
|
+
case 'service':
|
|
678
|
+
return `// Process business logic
|
|
560
679
|
const { data, operation } = input;
|
|
561
680
|
|
|
562
681
|
// Apply business rules
|
|
@@ -570,8 +689,9 @@ export default ${className};`;
|
|
|
570
689
|
result: result,
|
|
571
690
|
operation: operation
|
|
572
691
|
};`;
|
|
573
|
-
|
|
574
|
-
|
|
692
|
+
|
|
693
|
+
case 'repository':
|
|
694
|
+
return `// Handle data operations
|
|
575
695
|
const { operation, entity, data } = input;
|
|
576
696
|
|
|
577
697
|
switch (operation) {
|
|
@@ -586,32 +706,36 @@ export default ${className};`;
|
|
|
586
706
|
default:
|
|
587
707
|
throw new Error(\`Unknown operation: \${operation}\`);
|
|
588
708
|
}`;
|
|
589
|
-
|
|
590
|
-
|
|
709
|
+
|
|
710
|
+
default:
|
|
711
|
+
return `// Generic processing
|
|
591
712
|
const processedInput = await this.preProcess(input);
|
|
592
713
|
const result = await this.process(processedInput);
|
|
593
714
|
const finalResult = await this.postProcess(result);
|
|
594
715
|
|
|
595
716
|
return finalResult;`;
|
|
596
|
-
}
|
|
597
717
|
}
|
|
598
|
-
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
599
721
|
* Generate test file
|
|
600
|
-
*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
722
|
+
*/
|
|
723
|
+
generateTestFile(component) {
|
|
724
|
+
const className = component.name;
|
|
725
|
+
|
|
726
|
+
const code = `import { ${className} } from '../${component.type}/${className}';
|
|
727
|
+
${component.dependencies.map((dep) => `import { Mock${dep} } from '../mocks/Mock${dep}';`).join('\n')}
|
|
604
728
|
|
|
605
729
|
describe('${className}', () => {
|
|
606
730
|
let ${className.toLowerCase()};
|
|
607
|
-
${component.dependencies.map((dep)
|
|
731
|
+
${component.dependencies.map((dep) => `let mock${dep};`).join('\n ')}
|
|
608
732
|
|
|
609
733
|
beforeEach(async () => {
|
|
610
734
|
// Setup mocks
|
|
611
|
-
${component.dependencies.map((dep)
|
|
735
|
+
${component.dependencies.map((dep) => `mock${dep} = new Mock${dep}();`).join('\n ')}
|
|
612
736
|
|
|
613
737
|
// Create instance
|
|
614
|
-
${className.toLowerCase()} = new ${className}(${component.dependencies.map((dep)
|
|
738
|
+
${className.toLowerCase()} = new ${className}(${component.dependencies.map((dep) => `mock${dep}`).join(', ')});
|
|
615
739
|
|
|
616
740
|
// Initialize
|
|
617
741
|
await ${className.toLowerCase()}.initialize();
|
|
@@ -647,7 +771,7 @@ describe('${className}', () => {
|
|
|
647
771
|
});
|
|
648
772
|
|
|
649
773
|
test('should throw error when not initialized', async () => {
|
|
650
|
-
const uninitializedInstance = new ${className}(${component.dependencies.map((dep)
|
|
774
|
+
const uninitializedInstance = new ${className}(${component.dependencies.map((dep) => `mock${dep}`).join(', ')});
|
|
651
775
|
const input = ${this.generateValidTestInput(component)};
|
|
652
776
|
|
|
653
777
|
await expect(uninitializedInstance.execute(input)).rejects.toThrow();
|
|
@@ -678,56 +802,68 @@ describe('${className}', () => {
|
|
|
678
802
|
});
|
|
679
803
|
});
|
|
680
804
|
});`;
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
|
|
805
|
+
|
|
806
|
+
return {
|
|
807
|
+
name: `${className}.test.js`,
|
|
808
|
+
path: `tests/unit/${className}.test.js`,
|
|
809
|
+
type: 'test',
|
|
810
|
+
size: code.length,
|
|
811
|
+
lines: code.split('\n').length,
|
|
812
|
+
code: code,
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
691
817
|
* Generate valid test input for component
|
|
692
|
-
*/
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
818
|
+
*/
|
|
819
|
+
generateValidTestInput(component) {
|
|
820
|
+
const compType = component.type.toLowerCase();
|
|
821
|
+
|
|
822
|
+
switch (compType) {
|
|
823
|
+
case 'controller':
|
|
824
|
+
return `{
|
|
697
825
|
method: 'GET',
|
|
698
826
|
path: '/api/test',
|
|
699
827
|
body: {},
|
|
700
828
|
query: {}
|
|
701
829
|
}`;
|
|
702
|
-
|
|
703
|
-
|
|
830
|
+
|
|
831
|
+
case 'service':
|
|
832
|
+
return `{
|
|
704
833
|
data: { id: 1, name: 'test' },
|
|
705
834
|
operation: 'process'
|
|
706
835
|
}`;
|
|
707
|
-
|
|
708
|
-
|
|
836
|
+
|
|
837
|
+
case 'repository':
|
|
838
|
+
return `{
|
|
709
839
|
operation: 'read',
|
|
710
840
|
entity: 'User',
|
|
711
841
|
data: { id: 1 }
|
|
712
842
|
}`;
|
|
713
|
-
|
|
714
|
-
|
|
843
|
+
|
|
844
|
+
default:
|
|
845
|
+
return `{
|
|
715
846
|
id: 1,
|
|
716
847
|
data: 'test data',
|
|
717
848
|
timestamp: new Date().toISOString()
|
|
718
849
|
}`;
|
|
719
|
-
}
|
|
720
850
|
}
|
|
721
|
-
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
722
854
|
* Generate invalid test input for component
|
|
723
|
-
*/
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
855
|
+
*/
|
|
856
|
+
generateInvalidTestInput(component) {
|
|
857
|
+
return 'null';
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
727
861
|
* Generate interface file
|
|
728
|
-
*/
|
|
729
|
-
|
|
730
|
-
|
|
862
|
+
*/
|
|
863
|
+
generateInterfaceFile(component) {
|
|
864
|
+
const interfaceName = component.interfaces[0];
|
|
865
|
+
|
|
866
|
+
const code = `/**
|
|
731
867
|
* ${interfaceName} - Interface for ${component.name}
|
|
732
868
|
*/
|
|
733
869
|
export interface ${interfaceName} {
|
|
@@ -768,574 +904,679 @@ export interface ${interfaceName} {
|
|
|
768
904
|
}
|
|
769
905
|
|
|
770
906
|
export default ${interfaceName};`;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}
|
|
780
|
-
|
|
907
|
+
|
|
908
|
+
return {
|
|
909
|
+
name: `${interfaceName}.ts`,
|
|
910
|
+
path: `src/interfaces/${interfaceName}.ts`,
|
|
911
|
+
type: 'interface',
|
|
912
|
+
size: code.length,
|
|
913
|
+
lines: code.split('\n').length,
|
|
914
|
+
code: code,
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
781
919
|
* Run tests and collect results
|
|
782
|
-
*/
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
920
|
+
*/
|
|
921
|
+
async runTests(tddCycles) {
|
|
922
|
+
const testResults = {
|
|
923
|
+
total: 0,
|
|
924
|
+
passed: 0,
|
|
925
|
+
failed: 0,
|
|
926
|
+
skipped: 0,
|
|
927
|
+
coverage: 0,
|
|
928
|
+
duration: 0,
|
|
929
|
+
suites: [],
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
for (const cycle of tddCycles) {
|
|
933
|
+
if (cycle.success && cycle.refactorPhase) {
|
|
934
|
+
const suiteResult = {
|
|
935
|
+
name: cycle.requirement,
|
|
936
|
+
tests: cycle.refactorPhase.testResults.length,
|
|
937
|
+
passed: cycle.refactorPhase.testResults.filter((t) => t.passed).length,
|
|
938
|
+
failed: cycle.refactorPhase.testResults.filter((t) => !t.passed).length,
|
|
939
|
+
duration: cycle.duration,
|
|
940
|
+
coverage: 95 + Math.random() * 5, // 95-100% coverage
|
|
791
941
|
};
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
failed: cycle.refactorPhase.testResults.filter((t)=>!t.passed).length,
|
|
799
|
-
duration: cycle.duration,
|
|
800
|
-
coverage: 95 + Math.random() * 5
|
|
801
|
-
};
|
|
802
|
-
testResults.suites.push(suiteResult);
|
|
803
|
-
testResults.total += suiteResult.tests;
|
|
804
|
-
testResults.passed += suiteResult.passed;
|
|
805
|
-
testResults.failed += suiteResult.failed;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
testResults.coverage = testResults.total > 0 ? testResults.passed / testResults.total * 100 : 0;
|
|
809
|
-
testResults.duration = tddCycles.reduce((total, cycle)=>total + cycle.duration, 0);
|
|
810
|
-
return testResults;
|
|
942
|
+
|
|
943
|
+
testResults.suites.push(suiteResult);
|
|
944
|
+
testResults.total += suiteResult.tests;
|
|
945
|
+
testResults.passed += suiteResult.passed;
|
|
946
|
+
testResults.failed += suiteResult.failed;
|
|
947
|
+
}
|
|
811
948
|
}
|
|
812
|
-
|
|
949
|
+
|
|
950
|
+
testResults.coverage =
|
|
951
|
+
testResults.total > 0 ? (testResults.passed / testResults.total) * 100 : 0;
|
|
952
|
+
testResults.duration = tddCycles.reduce((total, cycle) => total + cycle.duration, 0);
|
|
953
|
+
|
|
954
|
+
return testResults;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
813
958
|
* Analyze code quality
|
|
814
|
-
*/
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
totalFiles: totalFiles,
|
|
843
|
-
totalLines: implementations.reduce((total, impl)=>total + impl.files.reduce((fileTotal, file)=>fileTotal + file.lines, 0), 0),
|
|
844
|
-
implementationFiles: implementations.reduce((total, impl)=>total + impl.files.filter((f)=>f.type === 'implementation').length, 0),
|
|
845
|
-
testFiles: implementations.reduce((total, impl)=>total + impl.files.filter((f)=>f.type === 'test').length, 0)
|
|
846
|
-
};
|
|
847
|
-
// Calculate quality scores
|
|
848
|
-
quality.complexity = Math.max(0, 100 - quality.metrics.averageComplexity * 10);
|
|
849
|
-
quality.maintainability = Math.max(0, 100 - quality.violations.length * 5);
|
|
850
|
-
quality.readability = Math.max(0, 100 - quality.metrics.averageFileSize / 20);
|
|
851
|
-
quality.testCoverage = 95; // High coverage from TDD
|
|
852
|
-
quality.duplication = Math.max(0, 100 - quality.violations.filter((v)=>v.type === 'duplication').length * 10);
|
|
853
|
-
quality.overall = (quality.maintainability + quality.readability + quality.complexity + quality.testCoverage + quality.duplication) / 5;
|
|
854
|
-
return quality;
|
|
959
|
+
*/
|
|
960
|
+
async analyzeCodeQuality(implementations) {
|
|
961
|
+
const quality = {
|
|
962
|
+
overall: 0,
|
|
963
|
+
maintainability: 0,
|
|
964
|
+
readability: 0,
|
|
965
|
+
complexity: 0,
|
|
966
|
+
duplication: 0,
|
|
967
|
+
testCoverage: 0,
|
|
968
|
+
violations: [],
|
|
969
|
+
metrics: {},
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
let totalSize = 0;
|
|
973
|
+
let totalComplexity = 0;
|
|
974
|
+
let totalFiles = 0;
|
|
975
|
+
|
|
976
|
+
for (const implementation of implementations) {
|
|
977
|
+
totalSize += implementation.size;
|
|
978
|
+
totalFiles += implementation.files.length;
|
|
979
|
+
|
|
980
|
+
// Calculate complexity score
|
|
981
|
+
const complexityScore = this.calculateComplexityScore(implementation.complexity);
|
|
982
|
+
totalComplexity += complexityScore;
|
|
983
|
+
|
|
984
|
+
// Check for violations
|
|
985
|
+
const violations = this.checkQualityViolations(implementation);
|
|
986
|
+
quality.violations.push(...violations);
|
|
855
987
|
}
|
|
856
|
-
|
|
988
|
+
|
|
989
|
+
// Calculate metrics
|
|
990
|
+
quality.metrics = {
|
|
991
|
+
averageFileSize: totalFiles > 0 ? totalSize / totalFiles : 0,
|
|
992
|
+
averageComplexity: implementations.length > 0 ? totalComplexity / implementations.length : 0,
|
|
993
|
+
totalFiles: totalFiles,
|
|
994
|
+
totalLines: implementations.reduce(
|
|
995
|
+
(total, impl) => total + impl.files.reduce((fileTotal, file) => fileTotal + file.lines, 0),
|
|
996
|
+
0,
|
|
997
|
+
),
|
|
998
|
+
implementationFiles: implementations.reduce(
|
|
999
|
+
(total, impl) => total + impl.files.filter((f) => f.type === 'implementation').length,
|
|
1000
|
+
0,
|
|
1001
|
+
),
|
|
1002
|
+
testFiles: implementations.reduce(
|
|
1003
|
+
(total, impl) => total + impl.files.filter((f) => f.type === 'test').length,
|
|
1004
|
+
0,
|
|
1005
|
+
),
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
// Calculate quality scores
|
|
1009
|
+
quality.complexity = Math.max(0, 100 - quality.metrics.averageComplexity * 10);
|
|
1010
|
+
quality.maintainability = Math.max(0, 100 - quality.violations.length * 5);
|
|
1011
|
+
quality.readability = Math.max(0, 100 - quality.metrics.averageFileSize / 20);
|
|
1012
|
+
quality.testCoverage = 95; // High coverage from TDD
|
|
1013
|
+
quality.duplication = Math.max(
|
|
1014
|
+
0,
|
|
1015
|
+
100 - quality.violations.filter((v) => v.type === 'duplication').length * 10,
|
|
1016
|
+
);
|
|
1017
|
+
|
|
1018
|
+
quality.overall =
|
|
1019
|
+
(quality.maintainability +
|
|
1020
|
+
quality.readability +
|
|
1021
|
+
quality.complexity +
|
|
1022
|
+
quality.testCoverage +
|
|
1023
|
+
quality.duplication) /
|
|
1024
|
+
5;
|
|
1025
|
+
|
|
1026
|
+
return quality;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
857
1030
|
* Calculate complexity score
|
|
858
|
-
*/
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
1031
|
+
*/
|
|
1032
|
+
calculateComplexityScore(complexity) {
|
|
1033
|
+
const scores = { low: 1, medium: 3, high: 5 };
|
|
1034
|
+
return scores[complexity] || 2;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
867
1038
|
* Check for quality violations
|
|
868
|
-
*/
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
violations.push({
|
|
893
|
-
type: 'dependencies',
|
|
894
|
-
severity: 'info',
|
|
895
|
-
message: `Component ${implementation.component} has ${implementation.dependencies.length} dependencies`,
|
|
896
|
-
component: implementation.component
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
return violations;
|
|
1039
|
+
*/
|
|
1040
|
+
checkQualityViolations(implementation) {
|
|
1041
|
+
const violations = [];
|
|
1042
|
+
|
|
1043
|
+
// Check file size
|
|
1044
|
+
for (const file of implementation.files) {
|
|
1045
|
+
if (file.lines > 500) {
|
|
1046
|
+
violations.push({
|
|
1047
|
+
type: 'file_size',
|
|
1048
|
+
severity: 'warning',
|
|
1049
|
+
message: `File ${file.name} has ${file.lines} lines (>500)`,
|
|
1050
|
+
file: file.name,
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// Check complexity
|
|
1056
|
+
if (implementation.complexity === 'high') {
|
|
1057
|
+
violations.push({
|
|
1058
|
+
type: 'complexity',
|
|
1059
|
+
severity: 'warning',
|
|
1060
|
+
message: `Component ${implementation.component} has high complexity`,
|
|
1061
|
+
component: implementation.component,
|
|
1062
|
+
});
|
|
900
1063
|
}
|
|
901
|
-
|
|
1064
|
+
|
|
1065
|
+
// Check dependencies
|
|
1066
|
+
if (implementation.dependencies.length > 5) {
|
|
1067
|
+
violations.push({
|
|
1068
|
+
type: 'dependencies',
|
|
1069
|
+
severity: 'info',
|
|
1070
|
+
message: `Component ${implementation.component} has ${implementation.dependencies.length} dependencies`,
|
|
1071
|
+
component: implementation.component,
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
return violations;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
902
1079
|
* Apply optimizations
|
|
903
|
-
*/
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
optimizations.push({
|
|
917
|
-
type: 'memory',
|
|
918
|
-
description: 'Implement object pooling for heavy objects',
|
|
919
|
-
impact: 'Reduce memory allocation overhead',
|
|
920
|
-
effort: 'low',
|
|
921
|
-
implementation: 'Use object pools for database connections'
|
|
922
|
-
});
|
|
923
|
-
// Database optimizations
|
|
924
|
-
optimizations.push({
|
|
925
|
-
type: 'database',
|
|
926
|
-
description: 'Add database query optimization',
|
|
927
|
-
impact: 'Reduce database load by 40%',
|
|
928
|
-
effort: 'medium',
|
|
929
|
-
implementation: 'Add indexes and query optimization'
|
|
930
|
-
});
|
|
931
|
-
// Code structure optimizations
|
|
932
|
-
if (codeQuality.complexity < 70) {
|
|
933
|
-
optimizations.push({
|
|
934
|
-
type: 'structure',
|
|
935
|
-
description: 'Refactor complex components',
|
|
936
|
-
impact: 'Improve maintainability',
|
|
937
|
-
effort: 'high',
|
|
938
|
-
implementation: 'Break down large classes into smaller ones'
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
return optimizations;
|
|
1080
|
+
*/
|
|
1081
|
+
async applyOptimizations(implementations, codeQuality) {
|
|
1082
|
+
const optimizations = [];
|
|
1083
|
+
|
|
1084
|
+
// Performance optimizations
|
|
1085
|
+
if (codeQuality.overall < 80) {
|
|
1086
|
+
optimizations.push({
|
|
1087
|
+
type: 'performance',
|
|
1088
|
+
description: 'Apply caching to frequently accessed data',
|
|
1089
|
+
impact: 'Reduce response time by 30-50%',
|
|
1090
|
+
effort: 'medium',
|
|
1091
|
+
implementation: 'Add Redis caching layer',
|
|
1092
|
+
});
|
|
942
1093
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
{
|
|
972
|
-
component: 'External API calls',
|
|
973
|
-
impact: 'Medium',
|
|
974
|
-
description: 'Third-party API latency 50-100ms',
|
|
975
|
-
recommendation: 'Implement caching and connection pooling'
|
|
976
|
-
}
|
|
977
|
-
],
|
|
978
|
-
recommendations: [
|
|
979
|
-
'Implement caching for frequently accessed data',
|
|
980
|
-
'Optimize database queries with proper indexing',
|
|
981
|
-
'Use connection pooling for external services',
|
|
982
|
-
'Implement async processing for non-critical operations'
|
|
983
|
-
]
|
|
984
|
-
};
|
|
985
|
-
return performance;
|
|
1094
|
+
|
|
1095
|
+
// Memory optimizations
|
|
1096
|
+
optimizations.push({
|
|
1097
|
+
type: 'memory',
|
|
1098
|
+
description: 'Implement object pooling for heavy objects',
|
|
1099
|
+
impact: 'Reduce memory allocation overhead',
|
|
1100
|
+
effort: 'low',
|
|
1101
|
+
implementation: 'Use object pools for database connections',
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
// Database optimizations
|
|
1105
|
+
optimizations.push({
|
|
1106
|
+
type: 'database',
|
|
1107
|
+
description: 'Add database query optimization',
|
|
1108
|
+
impact: 'Reduce database load by 40%',
|
|
1109
|
+
effort: 'medium',
|
|
1110
|
+
implementation: 'Add indexes and query optimization',
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
// Code structure optimizations
|
|
1114
|
+
if (codeQuality.complexity < 70) {
|
|
1115
|
+
optimizations.push({
|
|
1116
|
+
type: 'structure',
|
|
1117
|
+
description: 'Refactor complex components',
|
|
1118
|
+
impact: 'Improve maintainability',
|
|
1119
|
+
effort: 'high',
|
|
1120
|
+
implementation: 'Break down large classes into smaller ones',
|
|
1121
|
+
});
|
|
986
1122
|
}
|
|
987
|
-
|
|
1123
|
+
|
|
1124
|
+
return optimizations;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Analyze performance
|
|
1129
|
+
*/
|
|
1130
|
+
async analyzePerformance(implementations) {
|
|
1131
|
+
const performance = {
|
|
1132
|
+
responseTime: {
|
|
1133
|
+
average: 150,
|
|
1134
|
+
p95: 200,
|
|
1135
|
+
p99: 350,
|
|
1136
|
+
max: 500,
|
|
1137
|
+
},
|
|
1138
|
+
throughput: {
|
|
1139
|
+
requestsPerSecond: 1000,
|
|
1140
|
+
concurrent: 100,
|
|
1141
|
+
peak: 1500,
|
|
1142
|
+
},
|
|
1143
|
+
resource: {
|
|
1144
|
+
cpuUsage: 45,
|
|
1145
|
+
memoryUsage: 60,
|
|
1146
|
+
diskIO: 20,
|
|
1147
|
+
networkIO: 30,
|
|
1148
|
+
},
|
|
1149
|
+
bottlenecks: [
|
|
1150
|
+
{
|
|
1151
|
+
component: 'Database queries',
|
|
1152
|
+
impact: 'High',
|
|
1153
|
+
description: 'Complex queries taking 100-200ms',
|
|
1154
|
+
recommendation: 'Add indexes and query optimization',
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
component: 'External API calls',
|
|
1158
|
+
impact: 'Medium',
|
|
1159
|
+
description: 'Third-party API latency 50-100ms',
|
|
1160
|
+
recommendation: 'Implement caching and connection pooling',
|
|
1161
|
+
},
|
|
1162
|
+
],
|
|
1163
|
+
recommendations: [
|
|
1164
|
+
'Implement caching for frequently accessed data',
|
|
1165
|
+
'Optimize database queries with proper indexing',
|
|
1166
|
+
'Use connection pooling for external services',
|
|
1167
|
+
'Implement async processing for non-critical operations',
|
|
1168
|
+
],
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
return performance;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
988
1175
|
* Analyze security
|
|
989
|
-
*/
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1176
|
+
*/
|
|
1177
|
+
async analyzeSecurity(implementations) {
|
|
1178
|
+
const security = {
|
|
1179
|
+
vulnerabilities: [],
|
|
1180
|
+
threats: [],
|
|
1181
|
+
recommendations: [],
|
|
1182
|
+
score: 85,
|
|
1183
|
+
compliance: {
|
|
1184
|
+
owasp: 'Partial',
|
|
1185
|
+
gdpr: 'Compliant',
|
|
1186
|
+
iso27001: 'Partial',
|
|
1187
|
+
},
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
// Check for common vulnerabilities
|
|
1191
|
+
security.vulnerabilities = [
|
|
1192
|
+
{
|
|
1193
|
+
type: 'Input Validation',
|
|
1194
|
+
severity: 'Medium',
|
|
1195
|
+
description: 'Some inputs not fully validated',
|
|
1196
|
+
location: 'API endpoints',
|
|
1197
|
+
remediation: 'Implement comprehensive input validation',
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
type: 'Error Handling',
|
|
1201
|
+
severity: 'Low',
|
|
1202
|
+
description: 'Error messages may leak sensitive information',
|
|
1203
|
+
location: 'Error handlers',
|
|
1204
|
+
remediation: 'Sanitize error messages in production',
|
|
1205
|
+
},
|
|
1206
|
+
];
|
|
1207
|
+
|
|
1208
|
+
// Security recommendations
|
|
1209
|
+
security.recommendations = [
|
|
1210
|
+
'Implement rate limiting on all API endpoints',
|
|
1211
|
+
'Add comprehensive input validation and sanitization',
|
|
1212
|
+
'Use parameterized queries to prevent SQL injection',
|
|
1213
|
+
'Implement proper session management',
|
|
1214
|
+
'Add security headers (HSTS, CSP, etc.)',
|
|
1215
|
+
'Regular security audits and penetration testing',
|
|
1216
|
+
];
|
|
1217
|
+
|
|
1218
|
+
return security;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1030
1222
|
* Generate documentation
|
|
1031
|
-
*/
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1223
|
+
*/
|
|
1224
|
+
async generateDocumentation(implementations) {
|
|
1225
|
+
const documentation = {
|
|
1226
|
+
api: null,
|
|
1227
|
+
components: [],
|
|
1228
|
+
deployment: null,
|
|
1229
|
+
userGuide: null,
|
|
1230
|
+
developerGuide: null,
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// Generate API documentation
|
|
1234
|
+
documentation.api = this.generateApiDocumentation(implementations);
|
|
1235
|
+
|
|
1236
|
+
// Generate component documentation
|
|
1237
|
+
documentation.components = implementations.map((impl) =>
|
|
1238
|
+
this.generateComponentDocumentation(impl),
|
|
1239
|
+
);
|
|
1240
|
+
|
|
1241
|
+
// Generate deployment documentation
|
|
1242
|
+
documentation.deployment = this.generateDeploymentDocumentation();
|
|
1243
|
+
|
|
1244
|
+
// Generate user guide
|
|
1245
|
+
documentation.userGuide = this.generateUserGuide();
|
|
1246
|
+
|
|
1247
|
+
// Generate developer guide
|
|
1248
|
+
documentation.developerGuide = this.generateDeveloperGuide();
|
|
1249
|
+
|
|
1250
|
+
return documentation;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1052
1254
|
* Generate API documentation
|
|
1053
|
-
*/
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
/**
|
|
1255
|
+
*/
|
|
1256
|
+
generateApiDocumentation(implementations) {
|
|
1257
|
+
return {
|
|
1258
|
+
title: 'API Documentation',
|
|
1259
|
+
version: '1.0.0',
|
|
1260
|
+
description: 'RESTful API for the application',
|
|
1261
|
+
baseUrl: '/api/v1',
|
|
1262
|
+
endpoints: implementations
|
|
1263
|
+
.filter((impl) => impl.type === 'controller')
|
|
1264
|
+
.map((impl) => ({
|
|
1265
|
+
path: `/api/${impl.component.toLowerCase()}`,
|
|
1266
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
1267
|
+
description: `${impl.component} operations`,
|
|
1268
|
+
authentication: 'Bearer token required',
|
|
1269
|
+
})),
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1073
1274
|
* Generate component documentation
|
|
1074
|
-
*/
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1275
|
+
*/
|
|
1276
|
+
generateComponentDocumentation(implementation) {
|
|
1277
|
+
return {
|
|
1278
|
+
name: implementation.component,
|
|
1279
|
+
type: implementation.type,
|
|
1280
|
+
description: `${implementation.component} component documentation`,
|
|
1281
|
+
files: implementation.files.map((file) => ({
|
|
1282
|
+
name: file.name,
|
|
1283
|
+
path: file.path,
|
|
1284
|
+
type: file.type,
|
|
1285
|
+
lines: file.lines,
|
|
1286
|
+
})),
|
|
1287
|
+
dependencies: implementation.dependencies,
|
|
1288
|
+
interfaces: implementation.interfaces,
|
|
1289
|
+
usage: `Import and use ${implementation.component} for ${implementation.type} operations`,
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1091
1294
|
* Generate deployment documentation
|
|
1092
|
-
*/
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
/**
|
|
1295
|
+
*/
|
|
1296
|
+
generateDeploymentDocumentation() {
|
|
1297
|
+
return {
|
|
1298
|
+
title: 'Deployment Guide',
|
|
1299
|
+
prerequisites: [
|
|
1300
|
+
'Node.js 18+ installed',
|
|
1301
|
+
'npm or yarn package manager',
|
|
1302
|
+
'Database server configured',
|
|
1303
|
+
'Environment variables set',
|
|
1304
|
+
],
|
|
1305
|
+
steps: [
|
|
1306
|
+
'Clone the repository',
|
|
1307
|
+
'Install dependencies: npm install',
|
|
1308
|
+
'Configure environment variables',
|
|
1309
|
+
'Run database migrations',
|
|
1310
|
+
'Start the application: npm start',
|
|
1311
|
+
],
|
|
1312
|
+
environments: ['development', 'staging', 'production'],
|
|
1313
|
+
monitoring: 'Use provided health check endpoints',
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1117
1318
|
* Generate user guide
|
|
1118
|
-
*/
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1319
|
+
*/
|
|
1320
|
+
generateUserGuide() {
|
|
1321
|
+
return {
|
|
1322
|
+
title: 'User Guide',
|
|
1323
|
+
sections: [
|
|
1324
|
+
'Getting Started',
|
|
1325
|
+
'Basic Operations',
|
|
1326
|
+
'Advanced Features',
|
|
1327
|
+
'Troubleshooting',
|
|
1328
|
+
'FAQ',
|
|
1329
|
+
],
|
|
1330
|
+
description: 'Comprehensive guide for end users',
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1132
1335
|
* Generate developer guide
|
|
1133
|
-
*/
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1336
|
+
*/
|
|
1337
|
+
generateDeveloperGuide() {
|
|
1338
|
+
return {
|
|
1339
|
+
title: 'Developer Guide',
|
|
1340
|
+
sections: [
|
|
1341
|
+
'Architecture Overview',
|
|
1342
|
+
'Development Setup',
|
|
1343
|
+
'Code Standards',
|
|
1344
|
+
'Testing Guidelines',
|
|
1345
|
+
'Contribution Process',
|
|
1346
|
+
],
|
|
1347
|
+
description: 'Guide for developers contributing to the project',
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1147
1352
|
* Apply refactoring
|
|
1148
|
-
*/
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
refactoring.techniques.push({
|
|
1165
|
-
name: 'Extract Common Code',
|
|
1166
|
-
description: 'Remove code duplication by extracting common functionality',
|
|
1167
|
-
impact: 'Better maintainability and consistency'
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
if (codeQuality.maintainability < 80) {
|
|
1171
|
-
refactoring.techniques.push({
|
|
1172
|
-
name: 'Improve Naming',
|
|
1173
|
-
description: 'Use more descriptive variable and method names',
|
|
1174
|
-
impact: 'Better code understanding'
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
// Calculate improvements
|
|
1178
|
-
refactoring.improvements = [
|
|
1179
|
-
'Reduced cyclomatic complexity by 25%',
|
|
1180
|
-
'Eliminated code duplication',
|
|
1181
|
-
'Improved variable naming consistency',
|
|
1182
|
-
'Enhanced error handling',
|
|
1183
|
-
'Added comprehensive logging'
|
|
1184
|
-
];
|
|
1185
|
-
// Simulate improved quality after refactoring
|
|
1186
|
-
refactoring.after = {
|
|
1187
|
-
...codeQuality,
|
|
1188
|
-
complexity: Math.min(100, codeQuality.complexity + 15),
|
|
1189
|
-
maintainability: Math.min(100, codeQuality.maintainability + 20),
|
|
1190
|
-
readability: Math.min(100, codeQuality.readability + 10),
|
|
1191
|
-
duplication: Math.min(100, codeQuality.duplication + 25),
|
|
1192
|
-
overall: 0
|
|
1193
|
-
};
|
|
1194
|
-
refactoring.after.overall = (refactoring.after.complexity + refactoring.after.maintainability + refactoring.after.readability + refactoring.after.testCoverage + refactoring.after.duplication) / 5;
|
|
1195
|
-
return refactoring;
|
|
1353
|
+
*/
|
|
1354
|
+
async applyRefactoring(implementations, codeQuality) {
|
|
1355
|
+
const refactoring = {
|
|
1356
|
+
techniques: [],
|
|
1357
|
+
improvements: [],
|
|
1358
|
+
before: codeQuality,
|
|
1359
|
+
after: null,
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
// Apply refactoring techniques based on quality issues
|
|
1363
|
+
if (codeQuality.complexity < 70) {
|
|
1364
|
+
refactoring.techniques.push({
|
|
1365
|
+
name: 'Extract Method',
|
|
1366
|
+
description: 'Break down complex methods into smaller ones',
|
|
1367
|
+
impact: 'Improved readability and testability',
|
|
1368
|
+
});
|
|
1196
1369
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
issues: [],
|
|
1205
|
-
recommendations: []
|
|
1206
|
-
};
|
|
1207
|
-
// Check test coverage
|
|
1208
|
-
const testCoverageCheck = {
|
|
1209
|
-
name: 'Test Coverage',
|
|
1210
|
-
passed: result.testResults.coverage >= 80,
|
|
1211
|
-
score: result.testResults.coverage,
|
|
1212
|
-
threshold: 80,
|
|
1213
|
-
message: `Test coverage: ${result.testResults.coverage.toFixed(1)}%`
|
|
1214
|
-
};
|
|
1215
|
-
validation.checks.push(testCoverageCheck);
|
|
1216
|
-
// Check code quality
|
|
1217
|
-
const codeQualityCheck = {
|
|
1218
|
-
name: 'Code Quality',
|
|
1219
|
-
passed: result.codeQuality.overall >= 75,
|
|
1220
|
-
score: result.codeQuality.overall,
|
|
1221
|
-
threshold: 75,
|
|
1222
|
-
message: `Code quality score: ${result.codeQuality.overall.toFixed(1)}/100`
|
|
1223
|
-
};
|
|
1224
|
-
validation.checks.push(codeQualityCheck);
|
|
1225
|
-
// Check performance
|
|
1226
|
-
const performanceCheck = {
|
|
1227
|
-
name: 'Performance',
|
|
1228
|
-
passed: result.performance.responseTime.average < 200,
|
|
1229
|
-
score: 200 - result.performance.responseTime.average,
|
|
1230
|
-
threshold: 200,
|
|
1231
|
-
message: `Average response time: ${result.performance.responseTime.average}ms`
|
|
1232
|
-
};
|
|
1233
|
-
validation.checks.push(performanceCheck);
|
|
1234
|
-
// Check security
|
|
1235
|
-
const securityCheck = {
|
|
1236
|
-
name: 'Security',
|
|
1237
|
-
passed: result.security.score >= 80,
|
|
1238
|
-
score: result.security.score,
|
|
1239
|
-
threshold: 80,
|
|
1240
|
-
message: `Security score: ${result.security.score}/100`
|
|
1241
|
-
};
|
|
1242
|
-
validation.checks.push(securityCheck);
|
|
1243
|
-
// Check documentation
|
|
1244
|
-
const documentationCheck = {
|
|
1245
|
-
name: 'Documentation',
|
|
1246
|
-
passed: result.documentation.components.length > 0,
|
|
1247
|
-
score: result.documentation.components.length > 0 ? 100 : 0,
|
|
1248
|
-
threshold: 1,
|
|
1249
|
-
message: `Documentation: ${result.documentation.components.length} components documented`
|
|
1250
|
-
};
|
|
1251
|
-
validation.checks.push(documentationCheck);
|
|
1252
|
-
// Calculate overall score
|
|
1253
|
-
validation.score = validation.checks.reduce((sum, check)=>sum + (check.passed ? 20 : 0), 0);
|
|
1254
|
-
validation.passed = validation.checks.every((check)=>check.passed);
|
|
1255
|
-
// Collect issues
|
|
1256
|
-
validation.issues = validation.checks.filter((check)=>!check.passed).map((check)=>({
|
|
1257
|
-
category: check.name,
|
|
1258
|
-
severity: 'warning',
|
|
1259
|
-
message: `${check.name} below threshold: ${check.score} < ${check.threshold}`
|
|
1260
|
-
}));
|
|
1261
|
-
// Generate recommendations
|
|
1262
|
-
if (!testCoverageCheck.passed) {
|
|
1263
|
-
validation.recommendations.push('Increase test coverage by adding more unit tests');
|
|
1264
|
-
}
|
|
1265
|
-
if (!codeQualityCheck.passed) {
|
|
1266
|
-
validation.recommendations.push('Improve code quality by addressing complexity and maintainability issues');
|
|
1267
|
-
}
|
|
1268
|
-
if (!performanceCheck.passed) {
|
|
1269
|
-
validation.recommendations.push('Optimize performance by implementing caching and database optimization');
|
|
1270
|
-
}
|
|
1271
|
-
if (!securityCheck.passed) {
|
|
1272
|
-
validation.recommendations.push('Address security vulnerabilities and implement security best practices');
|
|
1273
|
-
}
|
|
1274
|
-
return validation;
|
|
1370
|
+
|
|
1371
|
+
if (codeQuality.duplication < 80) {
|
|
1372
|
+
refactoring.techniques.push({
|
|
1373
|
+
name: 'Extract Common Code',
|
|
1374
|
+
description: 'Remove code duplication by extracting common functionality',
|
|
1375
|
+
impact: 'Better maintainability and consistency',
|
|
1376
|
+
});
|
|
1275
1377
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1378
|
+
|
|
1379
|
+
if (codeQuality.maintainability < 80) {
|
|
1380
|
+
refactoring.techniques.push({
|
|
1381
|
+
name: 'Improve Naming',
|
|
1382
|
+
description: 'Use more descriptive variable and method names',
|
|
1383
|
+
impact: 'Better code understanding',
|
|
1384
|
+
});
|
|
1280
1385
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1386
|
+
|
|
1387
|
+
// Calculate improvements
|
|
1388
|
+
refactoring.improvements = [
|
|
1389
|
+
'Reduced cyclomatic complexity by 25%',
|
|
1390
|
+
'Eliminated code duplication',
|
|
1391
|
+
'Improved variable naming consistency',
|
|
1392
|
+
'Enhanced error handling',
|
|
1393
|
+
'Added comprehensive logging',
|
|
1394
|
+
];
|
|
1395
|
+
|
|
1396
|
+
// Simulate improved quality after refactoring
|
|
1397
|
+
refactoring.after = {
|
|
1398
|
+
...codeQuality,
|
|
1399
|
+
complexity: Math.min(100, codeQuality.complexity + 15),
|
|
1400
|
+
maintainability: Math.min(100, codeQuality.maintainability + 20),
|
|
1401
|
+
readability: Math.min(100, codeQuality.readability + 10),
|
|
1402
|
+
duplication: Math.min(100, codeQuality.duplication + 25),
|
|
1403
|
+
overall: 0,
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
refactoring.after.overall =
|
|
1407
|
+
(refactoring.after.complexity +
|
|
1408
|
+
refactoring.after.maintainability +
|
|
1409
|
+
refactoring.after.readability +
|
|
1410
|
+
refactoring.after.testCoverage +
|
|
1411
|
+
refactoring.after.duplication) /
|
|
1412
|
+
5;
|
|
1413
|
+
|
|
1414
|
+
return refactoring;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* Perform final validation
|
|
1419
|
+
*/
|
|
1420
|
+
async performFinalValidation(result) {
|
|
1421
|
+
const validation = {
|
|
1422
|
+
passed: true,
|
|
1423
|
+
score: 0,
|
|
1424
|
+
checks: [],
|
|
1425
|
+
issues: [],
|
|
1426
|
+
recommendations: [],
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
// Check test coverage
|
|
1430
|
+
const testCoverageCheck = {
|
|
1431
|
+
name: 'Test Coverage',
|
|
1432
|
+
passed: result.testResults.coverage >= 80,
|
|
1433
|
+
score: result.testResults.coverage,
|
|
1434
|
+
threshold: 80,
|
|
1435
|
+
message: `Test coverage: ${result.testResults.coverage.toFixed(1)}%`,
|
|
1436
|
+
};
|
|
1437
|
+
validation.checks.push(testCoverageCheck);
|
|
1438
|
+
|
|
1439
|
+
// Check code quality
|
|
1440
|
+
const codeQualityCheck = {
|
|
1441
|
+
name: 'Code Quality',
|
|
1442
|
+
passed: result.codeQuality.overall >= 75,
|
|
1443
|
+
score: result.codeQuality.overall,
|
|
1444
|
+
threshold: 75,
|
|
1445
|
+
message: `Code quality score: ${result.codeQuality.overall.toFixed(1)}/100`,
|
|
1446
|
+
};
|
|
1447
|
+
validation.checks.push(codeQualityCheck);
|
|
1448
|
+
|
|
1449
|
+
// Check performance
|
|
1450
|
+
const performanceCheck = {
|
|
1451
|
+
name: 'Performance',
|
|
1452
|
+
passed: result.performance.responseTime.average < 200,
|
|
1453
|
+
score: 200 - result.performance.responseTime.average,
|
|
1454
|
+
threshold: 200,
|
|
1455
|
+
message: `Average response time: ${result.performance.responseTime.average}ms`,
|
|
1456
|
+
};
|
|
1457
|
+
validation.checks.push(performanceCheck);
|
|
1458
|
+
|
|
1459
|
+
// Check security
|
|
1460
|
+
const securityCheck = {
|
|
1461
|
+
name: 'Security',
|
|
1462
|
+
passed: result.security.score >= 80,
|
|
1463
|
+
score: result.security.score,
|
|
1464
|
+
threshold: 80,
|
|
1465
|
+
message: `Security score: ${result.security.score}/100`,
|
|
1466
|
+
};
|
|
1467
|
+
validation.checks.push(securityCheck);
|
|
1468
|
+
|
|
1469
|
+
// Check documentation
|
|
1470
|
+
const documentationCheck = {
|
|
1471
|
+
name: 'Documentation',
|
|
1472
|
+
passed: result.documentation.components.length > 0,
|
|
1473
|
+
score: result.documentation.components.length > 0 ? 100 : 0,
|
|
1474
|
+
threshold: 1,
|
|
1475
|
+
message: `Documentation: ${result.documentation.components.length} components documented`,
|
|
1476
|
+
};
|
|
1477
|
+
validation.checks.push(documentationCheck);
|
|
1478
|
+
|
|
1479
|
+
// Calculate overall score
|
|
1480
|
+
validation.score = validation.checks.reduce((sum, check) => sum + (check.passed ? 20 : 0), 0);
|
|
1481
|
+
validation.passed = validation.checks.every((check) => check.passed);
|
|
1482
|
+
|
|
1483
|
+
// Collect issues
|
|
1484
|
+
validation.issues = validation.checks
|
|
1485
|
+
.filter((check) => !check.passed)
|
|
1486
|
+
.map((check) => ({
|
|
1487
|
+
category: check.name,
|
|
1488
|
+
severity: 'warning',
|
|
1489
|
+
message: `${check.name} below threshold: ${check.score} < ${check.threshold}`,
|
|
1490
|
+
}));
|
|
1491
|
+
|
|
1492
|
+
// Generate recommendations
|
|
1493
|
+
if (!testCoverageCheck.passed) {
|
|
1494
|
+
validation.recommendations.push('Increase test coverage by adding more unit tests');
|
|
1283
1495
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1496
|
+
if (!codeQualityCheck.passed) {
|
|
1497
|
+
validation.recommendations.push(
|
|
1498
|
+
'Improve code quality by addressing complexity and maintainability issues',
|
|
1499
|
+
);
|
|
1286
1500
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
passed: true
|
|
1292
|
-
},
|
|
1293
|
-
{
|
|
1294
|
-
assertion: 'result has expected structure',
|
|
1295
|
-
passed: true
|
|
1296
|
-
},
|
|
1297
|
-
{
|
|
1298
|
-
assertion: 'result matches expected values',
|
|
1299
|
-
passed: true
|
|
1300
|
-
}
|
|
1301
|
-
];
|
|
1501
|
+
if (!performanceCheck.passed) {
|
|
1502
|
+
validation.recommendations.push(
|
|
1503
|
+
'Optimize performance by implementing caching and database optimization',
|
|
1504
|
+
);
|
|
1302
1505
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
return '{ id: 1, data: "test" }';
|
|
1308
|
-
}
|
|
1506
|
+
if (!securityCheck.passed) {
|
|
1507
|
+
validation.recommendations.push(
|
|
1508
|
+
'Address security vulnerabilities and implement security best practices',
|
|
1509
|
+
);
|
|
1309
1510
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1511
|
+
|
|
1512
|
+
return validation;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Utility functions
|
|
1517
|
+
*/
|
|
1518
|
+
camelCase(str) {
|
|
1519
|
+
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase());
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
extractFunctionName(testName) {
|
|
1523
|
+
return testName.replace('test_', '').replace(/_/g, '');
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
findRelevantComponent(test, architecture) {
|
|
1527
|
+
return architecture.components.find(
|
|
1528
|
+
(comp) =>
|
|
1529
|
+
test.name.toLowerCase().includes(comp.name.toLowerCase()) ||
|
|
1530
|
+
test.description.toLowerCase().includes(comp.responsibility.toLowerCase()),
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
generateAssertions(test) {
|
|
1535
|
+
return [
|
|
1536
|
+
{ assertion: 'result is defined', passed: true },
|
|
1537
|
+
{ assertion: 'result has expected structure', passed: true },
|
|
1538
|
+
{ assertion: 'result matches expected values', passed: true },
|
|
1539
|
+
];
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
generateTestInput(testCase) {
|
|
1543
|
+
if (testCase.type === 'negative') {
|
|
1544
|
+
return 'null';
|
|
1545
|
+
} else {
|
|
1546
|
+
return '{ id: 1, data: "test" }';
|
|
1316
1547
|
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
generateExpectedOutput(testCase) {
|
|
1551
|
+
if (testCase.type === 'negative') {
|
|
1552
|
+
return 'Error';
|
|
1553
|
+
} else {
|
|
1554
|
+
return '{ success: true, data: { id: 1, processed: true } }';
|
|
1324
1555
|
}
|
|
1325
|
-
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
reduceComplexity(complexity) {
|
|
1559
|
+
const levels = { low: 'low', medium: 'low', high: 'medium' };
|
|
1560
|
+
return levels[complexity] || 'low';
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1326
1564
|
* Generate refinement document
|
|
1327
|
-
*/
|
|
1328
|
-
|
|
1565
|
+
*/
|
|
1566
|
+
async generateRefinementDocument(result) {
|
|
1567
|
+
const document = `# ${this.taskDescription} - Refinement
|
|
1329
1568
|
|
|
1330
1569
|
## TDD Cycles
|
|
1331
1570
|
|
|
1332
1571
|
### Summary
|
|
1333
1572
|
- **Total Cycles**: ${result.tddCycles.length}
|
|
1334
|
-
- **Successful**: ${result.tddCycles.filter((c)=>c.success).length}
|
|
1335
|
-
- **Failed**: ${result.tddCycles.filter((c)
|
|
1336
|
-
- **Average Duration**: ${(result.tddCycles.reduce((sum, c)=>sum + c.duration, 0) / result.tddCycles.length / 1000).toFixed(2)}s
|
|
1573
|
+
- **Successful**: ${result.tddCycles.filter((c) => c.success).length}
|
|
1574
|
+
- **Failed**: ${result.tddCycles.filter((c) => !c.success).length}
|
|
1575
|
+
- **Average Duration**: ${(result.tddCycles.reduce((sum, c) => sum + c.duration, 0) / result.tddCycles.length / 1000).toFixed(2)}s
|
|
1337
1576
|
|
|
1338
|
-
${result.tddCycles
|
|
1577
|
+
${result.tddCycles
|
|
1578
|
+
.map(
|
|
1579
|
+
(cycle, index) => `
|
|
1339
1580
|
### Cycle ${index + 1}: ${cycle.requirement}
|
|
1340
1581
|
**Status**: ${cycle.success ? '✅ Success' : '❌ Failed'}
|
|
1341
1582
|
**Duration**: ${(cycle.duration / 1000).toFixed(2)}s
|
|
@@ -1345,23 +1586,27 @@ ${result.tddCycles.map((cycle, index)=>`
|
|
|
1345
1586
|
- All Tests Failing: ${cycle.redPhase ? '✅' : '❌'}
|
|
1346
1587
|
|
|
1347
1588
|
#### GREEN Phase
|
|
1348
|
-
- Tests Passing: ${cycle.greenPhase ? cycle.greenPhase.testResults.filter((t)=>t.passed).length : 0}
|
|
1589
|
+
- Tests Passing: ${cycle.greenPhase ? cycle.greenPhase.testResults.filter((t) => t.passed).length : 0}
|
|
1349
1590
|
- Implementation Complete: ${cycle.greenPhase ? '✅' : '❌'}
|
|
1350
1591
|
|
|
1351
1592
|
#### REFACTOR Phase
|
|
1352
1593
|
- Refactoring Techniques: ${cycle.refactorPhase ? cycle.refactorPhase.refactorings.length : 0}
|
|
1353
1594
|
- Tests Still Passing: ${cycle.refactorPhase ? '✅' : '❌'}
|
|
1354
1595
|
- Code Quality Improved: ${cycle.refactorPhase ? '✅' : '❌'}
|
|
1355
|
-
|
|
1596
|
+
`,
|
|
1597
|
+
)
|
|
1598
|
+
.join('\n')}
|
|
1356
1599
|
|
|
1357
1600
|
## Implementations
|
|
1358
1601
|
|
|
1359
1602
|
### Summary
|
|
1360
1603
|
- **Components**: ${result.implementations.length}
|
|
1361
|
-
- **Total Files**: ${result.implementations.reduce((sum, impl)=>sum + impl.files.length, 0)}
|
|
1362
|
-
- **Total Lines**: ${result.implementations.reduce((sum, impl)=>sum + impl.files.reduce((fileSum, file)=>fileSum + file.lines, 0), 0)}
|
|
1604
|
+
- **Total Files**: ${result.implementations.reduce((sum, impl) => sum + impl.files.length, 0)}
|
|
1605
|
+
- **Total Lines**: ${result.implementations.reduce((sum, impl) => sum + impl.files.reduce((fileSum, file) => fileSum + file.lines, 0), 0)}
|
|
1363
1606
|
|
|
1364
|
-
${result.implementations
|
|
1607
|
+
${result.implementations
|
|
1608
|
+
.map(
|
|
1609
|
+
(impl, index) => `
|
|
1365
1610
|
### ${index + 1}. ${impl.component}
|
|
1366
1611
|
**Type**: ${impl.type}
|
|
1367
1612
|
**Files**: ${impl.files.length}
|
|
@@ -1372,27 +1617,33 @@ ${result.implementations.map((impl, index)=>`
|
|
|
1372
1617
|
**Complexity**: ${impl.complexity}
|
|
1373
1618
|
|
|
1374
1619
|
#### Files
|
|
1375
|
-
${impl.files.map((file)
|
|
1376
|
-
|
|
1620
|
+
${impl.files.map((file) => `- **${file.name}** (${file.type}): ${file.lines} lines`).join('\n')}
|
|
1621
|
+
`,
|
|
1622
|
+
)
|
|
1623
|
+
.join('\n')}
|
|
1377
1624
|
|
|
1378
1625
|
## Test Results
|
|
1379
1626
|
|
|
1380
1627
|
### Overall Results
|
|
1381
1628
|
- **Total Tests**: ${result.testResults.total}
|
|
1382
|
-
- **Passed**: ${result.testResults.passed} (${(result.testResults.passed / result.testResults.total * 100).toFixed(1)}%)
|
|
1629
|
+
- **Passed**: ${result.testResults.passed} (${((result.testResults.passed / result.testResults.total) * 100).toFixed(1)}%)
|
|
1383
1630
|
- **Failed**: ${result.testResults.failed}
|
|
1384
1631
|
- **Coverage**: ${result.testResults.coverage.toFixed(1)}%
|
|
1385
1632
|
- **Duration**: ${(result.testResults.duration / 1000).toFixed(2)}s
|
|
1386
1633
|
|
|
1387
1634
|
### Test Suites
|
|
1388
|
-
${result.testResults.suites
|
|
1635
|
+
${result.testResults.suites
|
|
1636
|
+
.map(
|
|
1637
|
+
(suite, index) => `
|
|
1389
1638
|
#### ${index + 1}. ${suite.name}
|
|
1390
1639
|
- **Tests**: ${suite.tests}
|
|
1391
1640
|
- **Passed**: ${suite.passed}
|
|
1392
1641
|
- **Failed**: ${suite.failed}
|
|
1393
1642
|
- **Coverage**: ${suite.coverage.toFixed(1)}%
|
|
1394
1643
|
- **Duration**: ${(suite.duration / 1000).toFixed(2)}s
|
|
1395
|
-
|
|
1644
|
+
`,
|
|
1645
|
+
)
|
|
1646
|
+
.join('\n')}
|
|
1396
1647
|
|
|
1397
1648
|
## Code Quality
|
|
1398
1649
|
|
|
@@ -1414,11 +1665,19 @@ ${result.testResults.suites.map((suite, index)=>`
|
|
|
1414
1665
|
- **Test Files**: ${result.codeQuality.metrics.testFiles}
|
|
1415
1666
|
|
|
1416
1667
|
### Quality Violations
|
|
1417
|
-
${
|
|
1668
|
+
${
|
|
1669
|
+
result.codeQuality.violations.length > 0
|
|
1670
|
+
? result.codeQuality.violations
|
|
1671
|
+
.map(
|
|
1672
|
+
(violation, index) => `
|
|
1418
1673
|
#### ${index + 1}. ${violation.type} (${violation.severity})
|
|
1419
1674
|
- **Message**: ${violation.message}
|
|
1420
1675
|
- **Location**: ${violation.file || violation.component || 'General'}
|
|
1421
|
-
|
|
1676
|
+
`,
|
|
1677
|
+
)
|
|
1678
|
+
.join('\n')
|
|
1679
|
+
: 'No quality violations found ✅'
|
|
1680
|
+
}
|
|
1422
1681
|
|
|
1423
1682
|
## Performance Analysis
|
|
1424
1683
|
|
|
@@ -1440,15 +1699,19 @@ ${result.codeQuality.violations.length > 0 ? result.codeQuality.violations.map((
|
|
|
1440
1699
|
- **Network I/O**: ${result.performance.resource.networkIO}%
|
|
1441
1700
|
|
|
1442
1701
|
### Bottlenecks
|
|
1443
|
-
${result.performance.bottlenecks
|
|
1702
|
+
${result.performance.bottlenecks
|
|
1703
|
+
.map(
|
|
1704
|
+
(bottleneck, index) => `
|
|
1444
1705
|
#### ${index + 1}. ${bottleneck.component}
|
|
1445
1706
|
- **Impact**: ${bottleneck.impact}
|
|
1446
1707
|
- **Description**: ${bottleneck.description}
|
|
1447
1708
|
- **Recommendation**: ${bottleneck.recommendation}
|
|
1448
|
-
|
|
1709
|
+
`,
|
|
1710
|
+
)
|
|
1711
|
+
.join('\n')}
|
|
1449
1712
|
|
|
1450
1713
|
### Performance Recommendations
|
|
1451
|
-
${result.performance.recommendations.map((rec, index)
|
|
1714
|
+
${result.performance.recommendations.map((rec, index) => `${index + 1}. ${rec}`).join('\n')}
|
|
1452
1715
|
|
|
1453
1716
|
## Security Analysis
|
|
1454
1717
|
|
|
@@ -1460,25 +1723,37 @@ ${result.performance.recommendations.map((rec, index)=>`${index + 1}. ${rec}`).j
|
|
|
1460
1723
|
- **ISO 27001**: ${result.security.compliance.iso27001}
|
|
1461
1724
|
|
|
1462
1725
|
### Vulnerabilities
|
|
1463
|
-
${
|
|
1726
|
+
${
|
|
1727
|
+
result.security.vulnerabilities.length > 0
|
|
1728
|
+
? result.security.vulnerabilities
|
|
1729
|
+
.map(
|
|
1730
|
+
(vuln, index) => `
|
|
1464
1731
|
#### ${index + 1}. ${vuln.type} (${vuln.severity})
|
|
1465
1732
|
- **Description**: ${vuln.description}
|
|
1466
1733
|
- **Location**: ${vuln.location}
|
|
1467
1734
|
- **Remediation**: ${vuln.remediation}
|
|
1468
|
-
|
|
1735
|
+
`,
|
|
1736
|
+
)
|
|
1737
|
+
.join('\n')
|
|
1738
|
+
: 'No security vulnerabilities found ✅'
|
|
1739
|
+
}
|
|
1469
1740
|
|
|
1470
1741
|
### Security Recommendations
|
|
1471
|
-
${result.security.recommendations.map((rec, index)
|
|
1742
|
+
${result.security.recommendations.map((rec, index) => `${index + 1}. ${rec}`).join('\n')}
|
|
1472
1743
|
|
|
1473
1744
|
## Optimizations Applied
|
|
1474
1745
|
|
|
1475
|
-
${result.optimizations
|
|
1746
|
+
${result.optimizations
|
|
1747
|
+
.map(
|
|
1748
|
+
(opt, index) => `
|
|
1476
1749
|
### ${index + 1}. ${opt.type} Optimization
|
|
1477
1750
|
- **Description**: ${opt.description}
|
|
1478
1751
|
- **Impact**: ${opt.impact}
|
|
1479
1752
|
- **Effort**: ${opt.effort}
|
|
1480
1753
|
- **Implementation**: ${opt.implementation}
|
|
1481
|
-
|
|
1754
|
+
`,
|
|
1755
|
+
)
|
|
1756
|
+
.join('\n')}
|
|
1482
1757
|
|
|
1483
1758
|
## Documentation Generated
|
|
1484
1759
|
|
|
@@ -1498,14 +1773,18 @@ ${result.optimizations.map((opt, index)=>`
|
|
|
1498
1773
|
## Refactoring Results
|
|
1499
1774
|
|
|
1500
1775
|
### Techniques Applied
|
|
1501
|
-
${result.refactoring.techniques
|
|
1776
|
+
${result.refactoring.techniques
|
|
1777
|
+
.map(
|
|
1778
|
+
(technique, index) => `
|
|
1502
1779
|
#### ${index + 1}. ${technique.name}
|
|
1503
1780
|
- **Description**: ${technique.description}
|
|
1504
1781
|
- **Impact**: ${technique.impact}
|
|
1505
|
-
|
|
1782
|
+
`,
|
|
1783
|
+
)
|
|
1784
|
+
.join('\n')}
|
|
1506
1785
|
|
|
1507
1786
|
### Improvements Achieved
|
|
1508
|
-
${result.refactoring.improvements.map((improvement, index)
|
|
1787
|
+
${result.refactoring.improvements.map((improvement, index) => `${index + 1}. ${improvement}`).join('\n')}
|
|
1509
1788
|
|
|
1510
1789
|
### Quality Improvement
|
|
1511
1790
|
- **Before**: ${result.refactoring.before.overall.toFixed(1)}/100
|
|
@@ -1517,48 +1796,62 @@ ${result.refactoring.improvements.map((improvement, index)=>`${index + 1}. ${imp
|
|
|
1517
1796
|
### Validation Score: ${result.validation.score}/100
|
|
1518
1797
|
|
|
1519
1798
|
### Checks Performed
|
|
1520
|
-
${result.validation.checks
|
|
1799
|
+
${result.validation.checks
|
|
1800
|
+
.map(
|
|
1801
|
+
(check, index) => `
|
|
1521
1802
|
#### ${index + 1}. ${check.name}
|
|
1522
1803
|
- **Status**: ${check.passed ? '✅ Passed' : '❌ Failed'}
|
|
1523
1804
|
- **Score**: ${check.score}/${check.threshold}
|
|
1524
1805
|
- **Message**: ${check.message}
|
|
1525
|
-
|
|
1806
|
+
`,
|
|
1807
|
+
)
|
|
1808
|
+
.join('\n')}
|
|
1526
1809
|
|
|
1527
|
-
${
|
|
1810
|
+
${
|
|
1811
|
+
result.validation.issues.length > 0
|
|
1812
|
+
? `
|
|
1528
1813
|
### Issues Found
|
|
1529
|
-
${result.validation.issues
|
|
1814
|
+
${result.validation.issues
|
|
1815
|
+
.map(
|
|
1816
|
+
(issue, index) => `
|
|
1530
1817
|
#### ${index + 1}. ${issue.category} (${issue.severity})
|
|
1531
1818
|
${issue.message}
|
|
1532
|
-
|
|
1819
|
+
`,
|
|
1820
|
+
)
|
|
1821
|
+
.join('\n')}`
|
|
1822
|
+
: '### No Issues Found ✅'
|
|
1823
|
+
}
|
|
1533
1824
|
|
|
1534
|
-
${
|
|
1825
|
+
${
|
|
1826
|
+
result.validation.recommendations.length > 0
|
|
1827
|
+
? `
|
|
1535
1828
|
### Recommendations
|
|
1536
|
-
${result.validation.recommendations.map((rec, index)
|
|
1829
|
+
${result.validation.recommendations.map((rec, index) => `${index + 1}. ${rec}`).join('\n')}`
|
|
1830
|
+
: ''
|
|
1831
|
+
}
|
|
1537
1832
|
|
|
1538
1833
|
## Summary
|
|
1539
1834
|
|
|
1540
1835
|
The refinement phase has been completed with TDD methodology, resulting in:
|
|
1541
1836
|
|
|
1542
|
-
- ✅ **${result.tddCycles.filter((c)=>c.success).length}/${result.tddCycles.length}** successful TDD cycles
|
|
1837
|
+
- ✅ **${result.tddCycles.filter((c) => c.success).length}/${result.tddCycles.length}** successful TDD cycles
|
|
1543
1838
|
- ✅ **${result.testResults.coverage.toFixed(1)}%** test coverage
|
|
1544
1839
|
- ✅ **${result.codeQuality.overall.toFixed(1)}/100** code quality score
|
|
1545
1840
|
- ✅ **${result.performance.responseTime.average}ms** average response time
|
|
1546
1841
|
- ✅ **${result.security.score}/100** security score
|
|
1547
1842
|
- ✅ **${result.validation.score}/100** final validation score
|
|
1548
1843
|
|
|
1549
|
-
${
|
|
1844
|
+
${
|
|
1845
|
+
result.validation.passed
|
|
1846
|
+
? '🎉 **All quality gates passed!** The implementation is ready for completion phase.'
|
|
1847
|
+
: '⚠️ **Some quality gates failed.** Please address the issues before proceeding to completion phase.'
|
|
1848
|
+
}
|
|
1550
1849
|
`;
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
super('refinement', taskDescription, options);
|
|
1557
|
-
this.tddCycles = [];
|
|
1558
|
-
this.implementations = [];
|
|
1559
|
-
this.optimizations = [];
|
|
1560
|
-
this.testResults = null;
|
|
1561
|
-
this.codeQuality = null;
|
|
1562
|
-
}
|
|
1850
|
+
|
|
1851
|
+
// Save document
|
|
1852
|
+
await this.saveArtifact('refinement.md', document);
|
|
1853
|
+
return document;
|
|
1854
|
+
}
|
|
1563
1855
|
}
|
|
1856
|
+
|
|
1564
1857
|
export default SparcRefinement;
|