claude-flow-novice 2.0.3 ā 2.0.4
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 +487 -668
- package/dist/src/cli/commands/index-validate.js +18 -29
- package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
- package/dist/src/cli/commands/neural-goal-init.js +92 -125
- package/dist/src/cli/commands/swarm-exec.js +317 -393
- package/dist/src/cli/commands/swarm.js +1 -1
- package/dist/src/cli/commands/validate-framework.js +983 -1100
- package/dist/src/cli/commands/validate.js +144 -223
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
- package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
- package/dist/src/cli/simple-commands/agent.js +157 -193
- package/dist/src/cli/simple-commands/analysis.js +336 -446
- package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
- package/dist/src/cli/simple-commands/automation.js +481 -469
- package/dist/src/cli/simple-commands/batch-manager.js +261 -313
- package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
- package/dist/src/cli/simple-commands/claude-track.js +68 -90
- package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
- package/dist/src/cli/simple-commands/config.js +245 -290
- package/dist/src/cli/simple-commands/coordination.js +182 -234
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
- package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
- package/dist/src/cli/simple-commands/github/github-api.js +535 -574
- package/dist/src/cli/simple-commands/github/init.js +276 -303
- package/dist/src/cli/simple-commands/github.js +222 -247
- package/dist/src/cli/simple-commands/goal.js +51 -63
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
- package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
- package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
- package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
- package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
- package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
- package/dist/src/cli/simple-commands/hive.js +90 -79
- package/dist/src/cli/simple-commands/hook-safety.js +431 -521
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
- package/dist/src/cli/simple-commands/hooks.js +1064 -1204
- package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
- package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
- package/dist/src/cli/simple-commands/init/help.js +104 -107
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
- package/dist/src/cli/simple-commands/init/index.js +1510 -1759
- package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
- package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
- package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
- package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
- package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
- package/dist/src/cli/simple-commands/init.js +1 -2
- package/dist/src/cli/simple-commands/mcp-health.js +131 -158
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
- package/dist/src/cli/simple-commands/mcp.js +345 -400
- package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
- package/dist/src/cli/simple-commands/memory.js +247 -311
- package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
- package/dist/src/cli/simple-commands/monitor.js +294 -363
- package/dist/src/cli/simple-commands/neural.js +51 -65
- package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
- package/dist/src/cli/simple-commands/pair-basic.js +528 -656
- package/dist/src/cli/simple-commands/pair-old.js +430 -543
- package/dist/src/cli/simple-commands/pair-working.js +615 -751
- package/dist/src/cli/simple-commands/pair.js +615 -751
- package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
- package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
- package/dist/src/cli/simple-commands/process-ui.js +230 -254
- package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
- package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
- package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
- package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
- package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
- package/dist/src/cli/simple-commands/sparc/index.js +241 -298
- package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
- package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
- package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
- 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 +47 -55
- 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 +101 -87
- 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 +465 -493
- package/dist/src/cli/simple-commands/start-ui.js +108 -132
- package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +254 -275
- package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
- package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
- package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
- package/dist/src/cli/simple-commands/stream-chain.js +260 -318
- package/dist/src/cli/simple-commands/stream-processor.js +290 -315
- package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
- package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
- package/dist/src/cli/simple-commands/swarm.js +887 -1082
- package/dist/src/cli/simple-commands/task.js +161 -206
- package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
- package/dist/src/cli/simple-commands/token-tracker.js +258 -316
- package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
- package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
- package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
- package/dist/src/cli/simple-commands/training.js +170 -227
- package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
- package/dist/src/cli/simple-commands/verification-integration.js +389 -417
- package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
- package/dist/src/cli/simple-commands/verification.js +493 -513
- package/dist/src/cli/simple-commands/web-server.js +766 -836
- package/dist/src/cli/simple-commands/webui-validator.js +106 -124
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
- package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
- package/dist/src/coordination/iteration-tracker.js +363 -454
- package/dist/src/enterprise/analytics-manager.js +1135 -0
- package/dist/src/enterprise/audit-manager.js +1115 -0
- package/dist/src/enterprise/cloud-manager.js +891 -0
- package/dist/src/enterprise/deployment-manager.js +966 -0
- package/dist/src/enterprise/index.js +6 -0
- package/dist/src/enterprise/project-manager.js +584 -0
- package/dist/src/enterprise/security-manager.js +991 -0
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/DEPRECATED.js +46 -60
- package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
- package/dist/src/mcp/implementations/agent-tracker.js +114 -128
- package/dist/src/mcp/implementations/daa-tools.js +292 -350
- package/dist/src/mcp/implementations/workflow-tools.js +329 -361
- package/dist/src/mcp/mcp-config-manager.js +1183 -1331
- package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
- package/dist/src/mcp/mcp-server-novice.js +11 -17
- package/dist/src/mcp/mcp-server-sdk.js +11 -17
- package/dist/src/mcp/mcp-server.js +1620 -1484
- package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
- package/dist/src/memory/advanced-serializer.js +609 -589
- package/dist/src/memory/enhanced-examples.js +220 -305
- package/dist/src/memory/enhanced-memory.js +295 -336
- package/dist/src/memory/enhanced-session-serializer.js +408 -492
- package/dist/src/memory/fallback-memory-system.js +900 -1021
- package/dist/src/memory/fallback-store.js +93 -131
- package/dist/src/memory/high-performance-serialization.js +592 -730
- package/dist/src/memory/in-memory-store.js +161 -213
- package/dist/src/memory/index.js +123 -157
- package/dist/src/memory/lock-free-structures.js +578 -764
- package/dist/src/memory/memory-mapped-persistence.js +585 -766
- package/dist/src/memory/memory-pressure-manager.js +569 -707
- package/dist/src/memory/migration.js +358 -445
- package/dist/src/memory/shared-memory.js +641 -768
- package/dist/src/memory/sqlite-store.js +245 -325
- package/dist/src/memory/sqlite-wrapper.js +122 -151
- package/dist/src/memory/swarm-memory.js +470 -603
- package/dist/src/memory/test-example.js +126 -134
- package/dist/src/memory/ultra-fast-memory-store.js +622 -821
- package/dist/src/memory/unified-memory-manager.js +356 -437
- package/dist/src/migration/index.js +92 -0
- package/dist/src/migration/logger.js +121 -0
- package/dist/src/migration/migration-analyzer.js +268 -0
- package/dist/src/migration/migration-runner.js +522 -0
- package/dist/src/migration/migration-validator.js +285 -0
- package/dist/src/migration/progress-reporter.js +150 -0
- package/dist/src/migration/rollback-manager.js +321 -0
- package/dist/src/migration/tests/migration-system.test.js +7 -0
- package/dist/src/migration/types.js +3 -0
- package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
- package/dist/src/swarm/__tests__/integration.test.js +227 -0
- package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
- package/dist/src/swarm/advanced-orchestrator.js +1095 -0
- package/dist/src/swarm/claude-code-interface.js +961 -0
- package/dist/src/swarm/claude-flow-executor.js +229 -0
- package/dist/src/swarm/consensus-coordinator.js +475 -0
- package/dist/src/swarm/coordinator.js +2993 -0
- package/dist/src/swarm/direct-executor.js +1180 -0
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
- package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
- package/dist/src/swarm/executor-v2.js +322 -0
- package/dist/src/swarm/executor.js +815 -0
- package/dist/src/swarm/hive-mind-integration.js +703 -0
- package/dist/src/swarm/index.js +41 -0
- package/dist/src/swarm/json-output-aggregator.js +267 -0
- package/dist/src/swarm/large-scale-coordinator.js +542 -0
- package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
- package/dist/src/swarm/memory.js +1117 -0
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
- package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
- package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
- package/dist/src/swarm/optimizations/connection-pool.js +244 -0
- package/dist/src/swarm/optimizations/index.js +28 -0
- package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
- package/dist/src/swarm/optimizations/ttl-map.js +234 -0
- package/dist/src/swarm/prompt-cli.js +200 -0
- package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
- package/dist/src/swarm/prompt-copier.js +381 -0
- package/dist/src/swarm/prompt-manager.js +295 -0
- package/dist/src/swarm/prompt-utils.js +310 -0
- package/dist/src/swarm/result-aggregator.js +718 -0
- package/dist/src/swarm/sparc-executor.js +1568 -0
- package/dist/src/swarm/strategies/auto.js +758 -0
- package/dist/src/swarm/strategies/base.js +128 -0
- package/dist/src/swarm/strategies/research.js +914 -0
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
- package/dist/src/swarm/types.js +52 -0
- package/dist/src/swarm/workers/copy-worker.js +56 -0
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
- package/dist/src/utils/github-cli-safe.js +56 -64
- package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
- package/dist/src/utils/npx-isolated-cache.js +104 -119
- package/dist/src/utils/preference-manager.js +622 -652
- package/dist/src/utils/timezone-utils.js +86 -105
- package/dist/src/validators/epic-config-schema.js +214 -0
- package/dist/src/validators/index.js +10 -0
- package/dist/src/validators/swarm-init-validator.js +259 -0
- package/dist/src/validators/todowrite-batching-validator.js +215 -0
- package/dist/src/validators/todowrite-integration.js +187 -0
- package/package.json +2 -2
|
@@ -2,77 +2,60 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Training Pipeline with Real Task Execution
|
|
4
4
|
* Executes actual code and learns from real test results
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import { promisify } from 'util';
|
|
11
|
-
import { exec } from 'child_process';
|
|
12
|
-
|
|
5
|
+
*/ import fs from "node:fs/promises";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
import { promisify } from "util";
|
|
9
|
+
import { exec } from "child_process";
|
|
13
10
|
const execAsync = promisify(exec);
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* Training Pipeline that executes real tasks and learns from actual results
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
constructor() {
|
|
20
|
-
this.pipelineConfig = '.claude-flow/pipeline-config.json';
|
|
21
|
-
this.trainingLog = '.claude-flow/training/pipeline-log.jsonl';
|
|
22
|
-
this.improvementMetrics = '.claude-flow/metrics/improvements.json';
|
|
23
|
-
this.agentProfiles = '.claude-flow/agents/profiles.json';
|
|
24
|
-
this.realTasksDir = '.claude-flow/training/real-tasks';
|
|
25
|
-
this.initialized = false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
13
|
+
*/ export class TrainingPipeline {
|
|
14
|
+
/**
|
|
29
15
|
* Initialize the training pipeline
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
16
|
+
*/ async initialize() {
|
|
17
|
+
// Create necessary directories
|
|
18
|
+
const dirs = [
|
|
19
|
+
'.claude-flow/pipeline',
|
|
20
|
+
'.claude-flow/training',
|
|
21
|
+
'.claude-flow/training/real-tasks',
|
|
22
|
+
'.claude-flow/metrics',
|
|
23
|
+
'.claude-flow/agents',
|
|
24
|
+
'.claude-flow/validation',
|
|
25
|
+
'.claude-flow/benchmarks'
|
|
26
|
+
];
|
|
27
|
+
for (const dir of dirs){
|
|
28
|
+
await fs.mkdir(dir, {
|
|
29
|
+
recursive: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Load or create pipeline configuration
|
|
33
|
+
await this.loadPipelineConfig();
|
|
34
|
+
console.log('š Training Pipeline initialized');
|
|
35
|
+
this.initialized = true;
|
|
45
36
|
}
|
|
46
|
-
|
|
47
|
-
// Load or create pipeline configuration
|
|
48
|
-
await this.loadPipelineConfig();
|
|
49
|
-
|
|
50
|
-
console.log('š Training Pipeline initialized');
|
|
51
|
-
this.initialized = true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
37
|
+
/**
|
|
55
38
|
* STAGE 1: Generate Training Tasks
|
|
56
39
|
* Creates actual code files that can be tested
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
40
|
+
*/ async generateTrainingTasks(complexity = 'medium') {
|
|
41
|
+
const taskId = Date.now();
|
|
42
|
+
const taskDir = path.join(this.realTasksDir, `task-${taskId}`);
|
|
43
|
+
await fs.mkdir(taskDir, {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
const tasks = {
|
|
47
|
+
easy: [
|
|
48
|
+
{
|
|
49
|
+
type: 'function',
|
|
50
|
+
name: 'validateEmail',
|
|
51
|
+
task: 'Create email validation function',
|
|
52
|
+
code: `function validateEmail(email) {
|
|
70
53
|
const regex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;
|
|
71
54
|
return regex.test(email);
|
|
72
55
|
}
|
|
73
56
|
|
|
74
57
|
module.exports = { validateEmail };`,
|
|
75
|
-
|
|
58
|
+
test: `
|
|
76
59
|
const { validateEmail } = require('./index');
|
|
77
60
|
|
|
78
61
|
describe('validateEmail', () => {
|
|
@@ -84,15 +67,15 @@ describe('validateEmail', () => {
|
|
|
84
67
|
expect(validateEmail('invalid')).toBe(false);
|
|
85
68
|
});
|
|
86
69
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
70
|
+
`
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
medium: [
|
|
74
|
+
{
|
|
75
|
+
type: 'api',
|
|
76
|
+
name: 'userApi',
|
|
77
|
+
task: 'Build user API endpoint',
|
|
78
|
+
code: `
|
|
96
79
|
const express = require('express');
|
|
97
80
|
const app = express();
|
|
98
81
|
|
|
@@ -116,7 +99,7 @@ app.post('/users', (req, res) => {
|
|
|
116
99
|
|
|
117
100
|
module.exports = app;
|
|
118
101
|
`,
|
|
119
|
-
|
|
102
|
+
test: `
|
|
120
103
|
const request = require('supertest');
|
|
121
104
|
const app = require('./index');
|
|
122
105
|
|
|
@@ -135,15 +118,15 @@ describe('User API', () => {
|
|
|
135
118
|
expect(res.body.name).toBe('Test');
|
|
136
119
|
});
|
|
137
120
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
121
|
+
`
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
hard: [
|
|
125
|
+
{
|
|
126
|
+
type: 'algorithm',
|
|
127
|
+
name: 'sortAlgorithm',
|
|
128
|
+
task: 'Implement efficient sorting',
|
|
129
|
+
code: `
|
|
147
130
|
function quickSort(arr) {
|
|
148
131
|
if (arr.length <= 1) return arr;
|
|
149
132
|
|
|
@@ -178,7 +161,7 @@ function mergeSort(arr) {
|
|
|
178
161
|
|
|
179
162
|
module.exports = { quickSort, mergeSort };
|
|
180
163
|
`,
|
|
181
|
-
|
|
164
|
+
test: `
|
|
182
165
|
const { quickSort, mergeSort } = require('./index');
|
|
183
166
|
|
|
184
167
|
describe('Sorting Algorithms', () => {
|
|
@@ -198,677 +181,588 @@ describe('Sorting Algorithms', () => {
|
|
|
198
181
|
expect(mergeSort([])).toEqual([]);
|
|
199
182
|
});
|
|
200
183
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
realTasks.push({
|
|
245
|
-
...task,
|
|
246
|
-
projectDir,
|
|
247
|
-
taskId,
|
|
248
|
-
});
|
|
184
|
+
`
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
};
|
|
188
|
+
const selectedTasks = tasks[complexity] || tasks.medium;
|
|
189
|
+
const realTasks = [];
|
|
190
|
+
// Create real task files
|
|
191
|
+
for (const task of selectedTasks){
|
|
192
|
+
const projectDir = path.join(taskDir, task.name);
|
|
193
|
+
await fs.mkdir(projectDir, {
|
|
194
|
+
recursive: true
|
|
195
|
+
});
|
|
196
|
+
// Write actual code file
|
|
197
|
+
await fs.writeFile(path.join(projectDir, 'index.js'), task.code);
|
|
198
|
+
// Write test file
|
|
199
|
+
await fs.writeFile(path.join(projectDir, 'index.test.js'), task.test);
|
|
200
|
+
// Create package.json with real dependencies
|
|
201
|
+
const packageJson = {
|
|
202
|
+
name: task.name,
|
|
203
|
+
version: '1.0.0',
|
|
204
|
+
scripts: {
|
|
205
|
+
test: 'jest --silent',
|
|
206
|
+
lint: 'eslint index.js || true',
|
|
207
|
+
typecheck: "echo 'No TypeScript' || true"
|
|
208
|
+
},
|
|
209
|
+
devDependencies: {
|
|
210
|
+
jest: '^29.0.0',
|
|
211
|
+
eslint: '^8.0.0',
|
|
212
|
+
supertest: '^6.0.0'
|
|
213
|
+
},
|
|
214
|
+
dependencies: {
|
|
215
|
+
express: task.type === 'api' ? '^4.18.0' : undefined
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
await fs.writeFile(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
219
|
+
realTasks.push({
|
|
220
|
+
...task,
|
|
221
|
+
projectDir,
|
|
222
|
+
taskId
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
console.log(`š Generated ${realTasks.length} ${complexity} training tasks`);
|
|
226
|
+
return realTasks;
|
|
249
227
|
}
|
|
250
|
-
|
|
251
|
-
console.log(`š Generated ${realTasks.length} ${complexity} training tasks`);
|
|
252
|
-
return realTasks;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
228
|
+
/**
|
|
256
229
|
* STAGE 2: Execute Tasks with Different Strategies
|
|
257
230
|
* Actually runs npm install, tests, and measures real performance
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
231
|
+
*/ async executeTrainingRun(tasks, agentConfig = {}) {
|
|
232
|
+
const results = [];
|
|
233
|
+
for (const task of tasks){
|
|
234
|
+
console.log(`\nš Executing task: ${task.task}`);
|
|
235
|
+
// Install dependencies (only once per task)
|
|
236
|
+
try {
|
|
237
|
+
console.log(` š¦ Installing dependencies...`);
|
|
238
|
+
execSync('npm install --silent', {
|
|
239
|
+
cwd: task.projectDir,
|
|
240
|
+
stdio: 'pipe'
|
|
241
|
+
});
|
|
242
|
+
} catch (e) {
|
|
243
|
+
console.log(` ā ļø Install warning: ${e.message.slice(0, 50)}`);
|
|
244
|
+
}
|
|
245
|
+
// Test different strategies with REAL variations
|
|
246
|
+
const strategies = agentConfig.strategies || [
|
|
247
|
+
'conservative',
|
|
248
|
+
'balanced',
|
|
249
|
+
'aggressive'
|
|
250
|
+
];
|
|
251
|
+
for (const strategy of strategies){
|
|
252
|
+
const result = await this.executeTaskWithStrategy(task, strategy);
|
|
253
|
+
results.push({
|
|
254
|
+
task: task.task,
|
|
255
|
+
type: task.type,
|
|
256
|
+
strategy,
|
|
257
|
+
...result,
|
|
258
|
+
timestamp: new Date().toISOString()
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// Save real results
|
|
263
|
+
const resultsFile = `.claude-flow/training/real-results-${Date.now()}.json`;
|
|
264
|
+
await fs.writeFile(resultsFile, JSON.stringify(results, null, 2));
|
|
265
|
+
return results;
|
|
289
266
|
}
|
|
290
|
-
|
|
291
|
-
// Save real results
|
|
292
|
-
const resultsFile = `.claude-flow/training/real-results-${Date.now()}.json`;
|
|
293
|
-
await fs.writeFile(resultsFile, JSON.stringify(results, null, 2));
|
|
294
|
-
|
|
295
|
-
return results;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
267
|
+
/**
|
|
299
268
|
* Execute a task with a specific strategy
|
|
300
269
|
* Strategies affect how we modify and test the code
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
passed
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
} else if (strategy === 'balanced' && successRate > 0.5 && executionTime < 2000) {
|
|
378
|
-
strategyBonus = 0.25; // Bonus for good balance
|
|
270
|
+
*/ async executeTaskWithStrategy(task, strategy) {
|
|
271
|
+
const startTime = Date.now();
|
|
272
|
+
const checks = {};
|
|
273
|
+
// Save original code
|
|
274
|
+
const originalCode = await fs.readFile(path.join(task.projectDir, 'index.js'), 'utf8');
|
|
275
|
+
// Modify code based on strategy (but more carefully!)
|
|
276
|
+
if (strategy === 'aggressive') {
|
|
277
|
+
// Aggressive: Skip some validation (but keep valid syntax)
|
|
278
|
+
const aggressiveCode = originalCode.replace(/if \(!(\w+)\)/g, 'if (false && !$1)');
|
|
279
|
+
await fs.writeFile(path.join(task.projectDir, 'index.js'), aggressiveCode);
|
|
280
|
+
} else if (strategy === 'conservative') {
|
|
281
|
+
// Conservative: Add validation at the top of functions
|
|
282
|
+
const conservativeCode = originalCode.replace(/function (\w+)\((.*?)\) {/g, 'function $1($2) {\n // Extra validation for conservative strategy\n if (arguments.length === 0) throw new Error("No arguments provided");');
|
|
283
|
+
await fs.writeFile(path.join(task.projectDir, 'index.js'), conservativeCode);
|
|
284
|
+
}
|
|
285
|
+
// Balanced: Keep original code
|
|
286
|
+
// Run REAL tests
|
|
287
|
+
try {
|
|
288
|
+
const testResult = execSync('npm test', {
|
|
289
|
+
cwd: task.projectDir,
|
|
290
|
+
encoding: 'utf8',
|
|
291
|
+
stdio: 'pipe'
|
|
292
|
+
});
|
|
293
|
+
checks.test = {
|
|
294
|
+
passed: true,
|
|
295
|
+
score: 1.0,
|
|
296
|
+
output: testResult.slice(0, 100)
|
|
297
|
+
};
|
|
298
|
+
} catch (e) {
|
|
299
|
+
checks.test = {
|
|
300
|
+
passed: false,
|
|
301
|
+
score: 0.3,
|
|
302
|
+
error: e.message.slice(0, 100)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
// Run REAL lint
|
|
306
|
+
try {
|
|
307
|
+
const lintResult = execSync('npm run lint', {
|
|
308
|
+
cwd: task.projectDir,
|
|
309
|
+
encoding: 'utf8',
|
|
310
|
+
stdio: 'pipe'
|
|
311
|
+
});
|
|
312
|
+
const hasErrors = lintResult.includes('error');
|
|
313
|
+
checks.lint = {
|
|
314
|
+
passed: !hasErrors,
|
|
315
|
+
score: hasErrors ? 0.5 : 1.0
|
|
316
|
+
};
|
|
317
|
+
} catch (e) {
|
|
318
|
+
checks.lint = {
|
|
319
|
+
passed: false,
|
|
320
|
+
score: 0.3
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
// Restore original code after testing
|
|
324
|
+
await fs.writeFile(path.join(task.projectDir, 'index.js'), originalCode);
|
|
325
|
+
// Calculate REAL performance metrics
|
|
326
|
+
const executionTime = Date.now() - startTime;
|
|
327
|
+
const successRate = Object.values(checks).filter((c)=>c.passed).length / Object.values(checks).length;
|
|
328
|
+
// Strategy-specific scoring based on REAL results
|
|
329
|
+
let strategyBonus = 0;
|
|
330
|
+
if (strategy === 'aggressive' && executionTime < 1000) {
|
|
331
|
+
strategyBonus = 0.2; // Bonus for fast execution
|
|
332
|
+
} else if (strategy === 'conservative' && successRate === 1.0) {
|
|
333
|
+
strategyBonus = 0.3; // Bonus for perfect reliability
|
|
334
|
+
} else if (strategy === 'balanced' && successRate > 0.5 && executionTime < 2000) {
|
|
335
|
+
strategyBonus = 0.25; // Bonus for good balance
|
|
336
|
+
}
|
|
337
|
+
const score = successRate * 60 + Math.max(0, 1 - executionTime / 5000) * 20 + strategyBonus * 20;
|
|
338
|
+
return {
|
|
339
|
+
executionTime,
|
|
340
|
+
successRate,
|
|
341
|
+
checks,
|
|
342
|
+
strategy,
|
|
343
|
+
score,
|
|
344
|
+
real: true
|
|
345
|
+
};
|
|
379
346
|
}
|
|
380
|
-
|
|
381
|
-
const score =
|
|
382
|
-
successRate * 60 + Math.max(0, 1 - executionTime / 5000) * 20 + strategyBonus * 20;
|
|
383
|
-
|
|
384
|
-
return {
|
|
385
|
-
executionTime,
|
|
386
|
-
successRate,
|
|
387
|
-
checks,
|
|
388
|
-
strategy,
|
|
389
|
-
score,
|
|
390
|
-
real: true, // Mark as real execution
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
347
|
+
/**
|
|
395
348
|
* STAGE 3: Learn from Results
|
|
396
349
|
* Updates profiles based on actual performance
|
|
397
|
-
*/
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
350
|
+
*/ async learnFromResults(results) {
|
|
351
|
+
console.log('\nš§ Learning from results...');
|
|
352
|
+
// Load current agent profiles
|
|
353
|
+
let profiles = {};
|
|
354
|
+
try {
|
|
355
|
+
const data = await fs.readFile(this.agentProfiles, 'utf8');
|
|
356
|
+
profiles = JSON.parse(data);
|
|
357
|
+
} catch {
|
|
358
|
+
profiles = this.getDefaultProfiles();
|
|
359
|
+
}
|
|
360
|
+
// Analyze REAL results by strategy
|
|
361
|
+
const strategyPerformance = {};
|
|
362
|
+
for (const result of results){
|
|
363
|
+
if (!strategyPerformance[result.strategy]) {
|
|
364
|
+
strategyPerformance[result.strategy] = {
|
|
365
|
+
totalScore: 0,
|
|
366
|
+
count: 0,
|
|
367
|
+
avgExecutionTime: 0,
|
|
368
|
+
successRate: 0,
|
|
369
|
+
realExecutions: 0
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
const perf = strategyPerformance[result.strategy];
|
|
373
|
+
perf.totalScore += result.score;
|
|
374
|
+
perf.count++;
|
|
375
|
+
perf.avgExecutionTime += result.executionTime;
|
|
376
|
+
perf.successRate += result.successRate;
|
|
377
|
+
if (result.real) perf.realExecutions++;
|
|
378
|
+
}
|
|
379
|
+
// Calculate averages and update profiles with REAL data
|
|
380
|
+
for (const [strategy, perf] of Object.entries(strategyPerformance)){
|
|
381
|
+
perf.avgScore = perf.totalScore / perf.count;
|
|
382
|
+
perf.avgExecutionTime = perf.avgExecutionTime / perf.count;
|
|
383
|
+
perf.successRate = perf.successRate / perf.count;
|
|
384
|
+
// Update with stronger learning for real executions
|
|
385
|
+
const learningRate = perf.realExecutions > 0 ? 0.4 : 0.1;
|
|
386
|
+
this.updateAgentProfile(profiles, strategy, perf, learningRate);
|
|
387
|
+
}
|
|
388
|
+
// Save updated profiles
|
|
389
|
+
await fs.writeFile(this.agentProfiles, JSON.stringify(profiles, null, 2));
|
|
390
|
+
// Generate recommendations based on performance
|
|
391
|
+
const recommendations = this.generateRecommendations(strategyPerformance);
|
|
392
|
+
console.log('\nš Learning Results:');
|
|
393
|
+
for (const [strategy, perf] of Object.entries(strategyPerformance)){
|
|
394
|
+
console.log(` ${strategy}: Score ${perf.avgScore.toFixed(2)}, Success ${(perf.successRate * 100).toFixed(1)}%, Time ${perf.avgExecutionTime.toFixed(0)}ms`);
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
profiles,
|
|
398
|
+
recommendations
|
|
420
399
|
};
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const perf = strategyPerformance[result.strategy];
|
|
424
|
-
perf.totalScore += result.score;
|
|
425
|
-
perf.count++;
|
|
426
|
-
perf.avgExecutionTime += result.executionTime;
|
|
427
|
-
perf.successRate += result.successRate;
|
|
428
|
-
if (result.real) perf.realExecutions++;
|
|
429
400
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
return { profiles, recommendations };
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
updateAgentProfile(profiles, strategy, performance, learningRate = 0.3) {
|
|
459
|
-
if (!profiles[strategy]) {
|
|
460
|
-
profiles[strategy] = {
|
|
461
|
-
successRate: 0.5,
|
|
462
|
-
avgScore: 50,
|
|
463
|
-
avgExecutionTime: 2000,
|
|
464
|
-
uses: 0,
|
|
465
|
-
realExecutions: 0,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
const profile = profiles[strategy];
|
|
470
|
-
|
|
471
|
-
// Update with exponential moving average
|
|
472
|
-
profile.successRate =
|
|
473
|
-
profile.successRate * (1 - learningRate) + performance.successRate * learningRate;
|
|
474
|
-
profile.avgScore = profile.avgScore * (1 - learningRate) + performance.avgScore * learningRate;
|
|
475
|
-
profile.avgExecutionTime =
|
|
476
|
-
profile.avgExecutionTime * (1 - learningRate) + performance.avgExecutionTime * learningRate;
|
|
477
|
-
profile.uses++;
|
|
478
|
-
if (performance.realExecutions) {
|
|
479
|
-
profile.realExecutions = (profile.realExecutions || 0) + performance.realExecutions;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// Add performance trend
|
|
483
|
-
if (!profile.trend) profile.trend = [];
|
|
484
|
-
profile.trend.push({
|
|
485
|
-
score: performance.avgScore,
|
|
486
|
-
timestamp: new Date().toISOString(),
|
|
487
|
-
real: performance.realExecutions > 0,
|
|
488
|
-
});
|
|
489
|
-
if (profile.trend.length > 20) {
|
|
490
|
-
profile.trend = profile.trend.slice(-20);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// Mark improvement
|
|
494
|
-
if (profile.trend.length > 1) {
|
|
495
|
-
const recent =
|
|
496
|
-
profile.trend.slice(-5).reduce((sum, t) => sum + t.score, 0) /
|
|
497
|
-
Math.min(5, profile.trend.length);
|
|
498
|
-
const older =
|
|
499
|
-
profile.trend.slice(0, -5).reduce((sum, t) => sum + t.score, 0) /
|
|
500
|
-
Math.max(1, profile.trend.length - 5);
|
|
501
|
-
profile.improving = recent > older;
|
|
502
|
-
profile.improvementRate = (((recent - older) / older) * 100).toFixed(1);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
generateRecommendations(strategyPerformance) {
|
|
507
|
-
const recommendations = [];
|
|
508
|
-
|
|
509
|
-
for (const [strategy, perf] of Object.entries(strategyPerformance)) {
|
|
510
|
-
if (perf.successRate < 0.7) {
|
|
511
|
-
recommendations.push({
|
|
512
|
-
type: 'improve_reliability',
|
|
513
|
-
strategy,
|
|
514
|
-
action: `${strategy} needs better error handling (${(perf.successRate * 100).toFixed(1)}% success)`,
|
|
515
|
-
priority: 'high',
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
if (perf.avgExecutionTime > 3000) {
|
|
520
|
-
recommendations.push({
|
|
521
|
-
type: 'optimize_speed',
|
|
522
|
-
strategy,
|
|
523
|
-
action: `${strategy} is too slow (${perf.avgExecutionTime.toFixed(0)}ms avg)`,
|
|
524
|
-
priority: 'medium',
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
if (perf.avgScore > 75) {
|
|
529
|
-
recommendations.push({
|
|
530
|
-
type: 'good_performance',
|
|
531
|
-
strategy,
|
|
532
|
-
action: `${strategy} performing well (${perf.avgScore.toFixed(1)} score)`,
|
|
533
|
-
priority: 'info',
|
|
401
|
+
updateAgentProfile(profiles, strategy, performance, learningRate = 0.3) {
|
|
402
|
+
if (!profiles[strategy]) {
|
|
403
|
+
profiles[strategy] = {
|
|
404
|
+
successRate: 0.5,
|
|
405
|
+
avgScore: 50,
|
|
406
|
+
avgExecutionTime: 2000,
|
|
407
|
+
uses: 0,
|
|
408
|
+
realExecutions: 0
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
const profile = profiles[strategy];
|
|
412
|
+
// Update with exponential moving average
|
|
413
|
+
profile.successRate = profile.successRate * (1 - learningRate) + performance.successRate * learningRate;
|
|
414
|
+
profile.avgScore = profile.avgScore * (1 - learningRate) + performance.avgScore * learningRate;
|
|
415
|
+
profile.avgExecutionTime = profile.avgExecutionTime * (1 - learningRate) + performance.avgExecutionTime * learningRate;
|
|
416
|
+
profile.uses++;
|
|
417
|
+
if (performance.realExecutions) {
|
|
418
|
+
profile.realExecutions = (profile.realExecutions || 0) + performance.realExecutions;
|
|
419
|
+
}
|
|
420
|
+
// Add performance trend
|
|
421
|
+
if (!profile.trend) profile.trend = [];
|
|
422
|
+
profile.trend.push({
|
|
423
|
+
score: performance.avgScore,
|
|
424
|
+
timestamp: new Date().toISOString(),
|
|
425
|
+
real: performance.realExecutions > 0
|
|
534
426
|
});
|
|
535
|
-
|
|
427
|
+
if (profile.trend.length > 20) {
|
|
428
|
+
profile.trend = profile.trend.slice(-20);
|
|
429
|
+
}
|
|
430
|
+
// Mark improvement
|
|
431
|
+
if (profile.trend.length > 1) {
|
|
432
|
+
const recent = profile.trend.slice(-5).reduce((sum, t)=>sum + t.score, 0) / Math.min(5, profile.trend.length);
|
|
433
|
+
const older = profile.trend.slice(0, -5).reduce((sum, t)=>sum + t.score, 0) / Math.max(1, profile.trend.length - 5);
|
|
434
|
+
profile.improving = recent > older;
|
|
435
|
+
profile.improvementRate = ((recent - older) / older * 100).toFixed(1);
|
|
436
|
+
}
|
|
536
437
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
438
|
+
generateRecommendations(strategyPerformance) {
|
|
439
|
+
const recommendations = [];
|
|
440
|
+
for (const [strategy, perf] of Object.entries(strategyPerformance)){
|
|
441
|
+
if (perf.successRate < 0.7) {
|
|
442
|
+
recommendations.push({
|
|
443
|
+
type: 'improve_reliability',
|
|
444
|
+
strategy,
|
|
445
|
+
action: `${strategy} needs better error handling (${(perf.successRate * 100).toFixed(1)}% success)`,
|
|
446
|
+
priority: 'high'
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
if (perf.avgExecutionTime > 3000) {
|
|
450
|
+
recommendations.push({
|
|
451
|
+
type: 'optimize_speed',
|
|
452
|
+
strategy,
|
|
453
|
+
action: `${strategy} is too slow (${perf.avgExecutionTime.toFixed(0)}ms avg)`,
|
|
454
|
+
priority: 'medium'
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
if (perf.avgScore > 75) {
|
|
458
|
+
recommendations.push({
|
|
459
|
+
type: 'good_performance',
|
|
460
|
+
strategy,
|
|
461
|
+
action: `${strategy} performing well (${perf.avgScore.toFixed(1)} score)`,
|
|
462
|
+
priority: 'info'
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return recommendations;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
542
469
|
* Full Training Pipeline Execution
|
|
543
|
-
*/
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
470
|
+
*/ async runFullPipeline(options = {}) {
|
|
471
|
+
const { complexity = 'medium', iterations = 3, validate = true } = options;
|
|
472
|
+
console.log('šÆ Starting Training Pipeline');
|
|
473
|
+
console.log('ā'.repeat(50));
|
|
474
|
+
await this.initialize();
|
|
475
|
+
// Capture baseline metrics
|
|
476
|
+
const baselineMetrics = await this.captureMetrics();
|
|
477
|
+
let cumulativeResults = [];
|
|
478
|
+
for(let i = 1; i <= iterations; i++){
|
|
479
|
+
console.log(`\nš Iteration ${i}/${iterations}`);
|
|
480
|
+
console.log('ā'.repeat(40));
|
|
481
|
+
// Stage 1: Generate tasks
|
|
482
|
+
const tasks = await this.generateTrainingTasks(complexity);
|
|
483
|
+
// Stage 2: Execute with real code
|
|
484
|
+
const results = await this.executeTrainingRun(tasks);
|
|
485
|
+
cumulativeResults = [
|
|
486
|
+
...cumulativeResults,
|
|
487
|
+
...results
|
|
488
|
+
];
|
|
489
|
+
// Stage 3: Learn from results
|
|
490
|
+
const { profiles, recommendations } = await this.learnFromResults(results);
|
|
491
|
+
// Show recommendations
|
|
492
|
+
if (recommendations.length > 0) {
|
|
493
|
+
console.log('\nš” Recommendations:');
|
|
494
|
+
for (const rec of recommendations.slice(0, 3)){
|
|
495
|
+
console.log(` ⢠${rec.action}`);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
// Stage 4: Validate if enabled
|
|
499
|
+
if (validate && i === iterations) {
|
|
500
|
+
const currentMetrics = await this.captureMetrics();
|
|
501
|
+
const validation = await this.validateImprovements(baselineMetrics, currentMetrics);
|
|
502
|
+
if (validation.summary.overallImprovement) {
|
|
503
|
+
console.log('ā
Improvement detected!');
|
|
504
|
+
} else {
|
|
505
|
+
console.log('ā ļø More training needed for significant improvement');
|
|
506
|
+
}
|
|
507
|
+
}
|
|
576
508
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
509
|
+
// Generate final report
|
|
510
|
+
const report = await this.generateFinalReport(cumulativeResults);
|
|
511
|
+
console.log('\n' + report);
|
|
512
|
+
return {
|
|
513
|
+
success: true,
|
|
514
|
+
totalTasks: cumulativeResults.length,
|
|
515
|
+
realExecutions: cumulativeResults.filter((r)=>r.real).length,
|
|
516
|
+
improvements: await this.calculateOverallImprovement(baselineMetrics)
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
// Reuse helper methods from original
|
|
520
|
+
async captureMetrics() {
|
|
521
|
+
try {
|
|
522
|
+
const data = await fs.readFile(this.agentProfiles, 'utf8');
|
|
523
|
+
const profiles = JSON.parse(data);
|
|
524
|
+
// Calculate weighted average from all strategies
|
|
525
|
+
let totalScore = 0;
|
|
526
|
+
let totalSuccess = 0;
|
|
527
|
+
let totalTime = 0;
|
|
528
|
+
let count = 0;
|
|
529
|
+
for (const profile of Object.values(profiles)){
|
|
530
|
+
if (profile.uses > 0) {
|
|
531
|
+
totalScore += profile.avgScore;
|
|
532
|
+
totalSuccess += profile.successRate;
|
|
533
|
+
totalTime += profile.avgExecutionTime;
|
|
534
|
+
count++;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
successRate: count > 0 ? totalSuccess / count : 0,
|
|
539
|
+
executionTime: count > 0 ? totalTime / count : 0,
|
|
540
|
+
score: count > 0 ? totalScore / count : 0
|
|
541
|
+
};
|
|
542
|
+
} catch {
|
|
543
|
+
return {
|
|
544
|
+
successRate: 0,
|
|
545
|
+
executionTime: 0,
|
|
546
|
+
score: 0
|
|
547
|
+
};
|
|
588
548
|
}
|
|
589
|
-
}
|
|
590
549
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
550
|
+
async validateImprovements(beforeMetrics, afterMetrics) {
|
|
551
|
+
const validation = {
|
|
552
|
+
improved: [],
|
|
553
|
+
declined: [],
|
|
554
|
+
unchanged: [],
|
|
555
|
+
summary: {}
|
|
556
|
+
};
|
|
557
|
+
const metrics = [
|
|
558
|
+
'successRate',
|
|
559
|
+
'executionTime',
|
|
560
|
+
'score'
|
|
561
|
+
];
|
|
562
|
+
for (const metric of metrics){
|
|
563
|
+
const before = beforeMetrics[metric] || 0.01; // Avoid division by zero
|
|
564
|
+
const after = afterMetrics[metric] || 0;
|
|
565
|
+
const change = after - before;
|
|
566
|
+
const percentChange = change / before * 100;
|
|
567
|
+
if (percentChange > 5) {
|
|
568
|
+
validation.improved.push({
|
|
569
|
+
metric,
|
|
570
|
+
change: percentChange
|
|
571
|
+
});
|
|
572
|
+
} else if (percentChange < -5) {
|
|
573
|
+
validation.declined.push({
|
|
574
|
+
metric,
|
|
575
|
+
change: percentChange
|
|
576
|
+
});
|
|
577
|
+
} else {
|
|
578
|
+
validation.unchanged.push({
|
|
579
|
+
metric,
|
|
580
|
+
change: percentChange
|
|
581
|
+
});
|
|
582
|
+
}
|
|
622
583
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
executionTime: 0,
|
|
634
|
-
score: 0,
|
|
635
|
-
};
|
|
584
|
+
validation.summary = {
|
|
585
|
+
overallImprovement: validation.improved.length > validation.declined.length,
|
|
586
|
+
improvementScore: validation.improved.length - validation.declined.length,
|
|
587
|
+
timestamp: new Date().toISOString()
|
|
588
|
+
};
|
|
589
|
+
console.log(`\nā
Validating improvements...`);
|
|
590
|
+
console.log(` Improved: ${validation.improved.length} metrics`);
|
|
591
|
+
console.log(` Declined: ${validation.declined.length} metrics`);
|
|
592
|
+
console.log(` Unchanged: ${validation.unchanged.length} metrics`);
|
|
593
|
+
return validation;
|
|
636
594
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
for (const metric of metrics) {
|
|
650
|
-
const before = beforeMetrics[metric] || 0.01; // Avoid division by zero
|
|
651
|
-
const after = afterMetrics[metric] || 0;
|
|
652
|
-
const change = after - before;
|
|
653
|
-
const percentChange = (change / before) * 100;
|
|
654
|
-
|
|
655
|
-
if (percentChange > 5) {
|
|
656
|
-
validation.improved.push({ metric, change: percentChange });
|
|
657
|
-
} else if (percentChange < -5) {
|
|
658
|
-
validation.declined.push({ metric, change: percentChange });
|
|
659
|
-
} else {
|
|
660
|
-
validation.unchanged.push({ metric, change: percentChange });
|
|
661
|
-
}
|
|
595
|
+
async calculateOverallImprovement(baselineMetrics) {
|
|
596
|
+
const currentMetrics = await this.captureMetrics();
|
|
597
|
+
const base = {
|
|
598
|
+
successRate: baselineMetrics.successRate || 0.01,
|
|
599
|
+
executionTime: baselineMetrics.executionTime || 1,
|
|
600
|
+
score: baselineMetrics.score || 0.01
|
|
601
|
+
};
|
|
602
|
+
return {
|
|
603
|
+
successRate: (currentMetrics.successRate - base.successRate) / base.successRate * 100,
|
|
604
|
+
executionTime: (base.executionTime - currentMetrics.executionTime) / base.executionTime * 100,
|
|
605
|
+
score: (currentMetrics.score - base.score) / base.score * 100
|
|
606
|
+
};
|
|
662
607
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
async generateFinalReport(results) {
|
|
696
|
-
const realResults = results.filter((r) => r.real);
|
|
697
|
-
const successRates = {};
|
|
698
|
-
const scores = {};
|
|
699
|
-
const times = {};
|
|
700
|
-
|
|
701
|
-
for (const result of realResults) {
|
|
702
|
-
if (!successRates[result.strategy]) {
|
|
703
|
-
successRates[result.strategy] = [];
|
|
704
|
-
scores[result.strategy] = [];
|
|
705
|
-
times[result.strategy] = [];
|
|
706
|
-
}
|
|
707
|
-
successRates[result.strategy].push(result.successRate);
|
|
708
|
-
scores[result.strategy].push(result.score);
|
|
709
|
-
times[result.strategy].push(result.executionTime);
|
|
608
|
+
async generateFinalReport(results) {
|
|
609
|
+
const realResults = results.filter((r)=>r.real);
|
|
610
|
+
const successRates = {};
|
|
611
|
+
const scores = {};
|
|
612
|
+
const times = {};
|
|
613
|
+
for (const result of realResults){
|
|
614
|
+
if (!successRates[result.strategy]) {
|
|
615
|
+
successRates[result.strategy] = [];
|
|
616
|
+
scores[result.strategy] = [];
|
|
617
|
+
times[result.strategy] = [];
|
|
618
|
+
}
|
|
619
|
+
successRates[result.strategy].push(result.successRate);
|
|
620
|
+
scores[result.strategy].push(result.score);
|
|
621
|
+
times[result.strategy].push(result.executionTime);
|
|
622
|
+
}
|
|
623
|
+
let report = 'š Training Pipeline Report\n';
|
|
624
|
+
report += 'ā'.repeat(50) + '\n\n';
|
|
625
|
+
for (const strategy of Object.keys(successRates)){
|
|
626
|
+
const avgSuccess = successRates[strategy].reduce((a, b)=>a + b, 0) / successRates[strategy].length;
|
|
627
|
+
const avgScore = scores[strategy].reduce((a, b)=>a + b, 0) / scores[strategy].length;
|
|
628
|
+
const avgTime = times[strategy].reduce((a, b)=>a + b, 0) / times[strategy].length;
|
|
629
|
+
report += `Strategy: ${strategy}\n`;
|
|
630
|
+
report += ` Average Success Rate: ${(avgSuccess * 100).toFixed(1)}%\n`;
|
|
631
|
+
report += ` Average Score: ${avgScore.toFixed(2)}\n`;
|
|
632
|
+
report += ` Average Time: ${avgTime.toFixed(0)}ms\n`;
|
|
633
|
+
report += ` Real Executions: ${successRates[strategy].length}\n`;
|
|
634
|
+
report += '\n';
|
|
635
|
+
}
|
|
636
|
+
return report;
|
|
710
637
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
638
|
+
getDefaultProfiles() {
|
|
639
|
+
return {
|
|
640
|
+
conservative: {
|
|
641
|
+
successRate: 0.5,
|
|
642
|
+
avgScore: 50,
|
|
643
|
+
avgExecutionTime: 3000,
|
|
644
|
+
uses: 0,
|
|
645
|
+
realExecutions: 0
|
|
646
|
+
},
|
|
647
|
+
balanced: {
|
|
648
|
+
successRate: 0.5,
|
|
649
|
+
avgScore: 50,
|
|
650
|
+
avgExecutionTime: 2000,
|
|
651
|
+
uses: 0,
|
|
652
|
+
realExecutions: 0
|
|
653
|
+
},
|
|
654
|
+
aggressive: {
|
|
655
|
+
successRate: 0.5,
|
|
656
|
+
avgScore: 50,
|
|
657
|
+
avgExecutionTime: 1000,
|
|
658
|
+
uses: 0,
|
|
659
|
+
realExecutions: 0
|
|
660
|
+
}
|
|
661
|
+
};
|
|
727
662
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
async loadPipelineConfig() {
|
|
759
|
-
try {
|
|
760
|
-
const data = await fs.readFile(this.pipelineConfig, 'utf8');
|
|
761
|
-
return JSON.parse(data);
|
|
762
|
-
} catch {
|
|
763
|
-
const defaultConfig = {
|
|
764
|
-
version: '2.0.0',
|
|
765
|
-
strategies: ['conservative', 'balanced', 'aggressive'],
|
|
766
|
-
learningRate: 0.4,
|
|
767
|
-
minSamplesForUpdate: 3,
|
|
768
|
-
useRealExecution: true,
|
|
769
|
-
created: new Date().toISOString(),
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
await fs.writeFile(this.pipelineConfig, JSON.stringify(defaultConfig, null, 2));
|
|
773
|
-
return defaultConfig;
|
|
663
|
+
async loadPipelineConfig() {
|
|
664
|
+
try {
|
|
665
|
+
const data = await fs.readFile(this.pipelineConfig, 'utf8');
|
|
666
|
+
return JSON.parse(data);
|
|
667
|
+
} catch {
|
|
668
|
+
const defaultConfig = {
|
|
669
|
+
version: '2.0.0',
|
|
670
|
+
strategies: [
|
|
671
|
+
'conservative',
|
|
672
|
+
'balanced',
|
|
673
|
+
'aggressive'
|
|
674
|
+
],
|
|
675
|
+
learningRate: 0.4,
|
|
676
|
+
minSamplesForUpdate: 3,
|
|
677
|
+
useRealExecution: true,
|
|
678
|
+
created: new Date().toISOString()
|
|
679
|
+
};
|
|
680
|
+
await fs.writeFile(this.pipelineConfig, JSON.stringify(defaultConfig, null, 2));
|
|
681
|
+
return defaultConfig;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
constructor(){
|
|
685
|
+
this.pipelineConfig = '.claude-flow/pipeline-config.json';
|
|
686
|
+
this.trainingLog = '.claude-flow/training/pipeline-log.jsonl';
|
|
687
|
+
this.improvementMetrics = '.claude-flow/metrics/improvements.json';
|
|
688
|
+
this.agentProfiles = '.claude-flow/agents/profiles.json';
|
|
689
|
+
this.realTasksDir = '.claude-flow/training/real-tasks';
|
|
690
|
+
this.initialized = false;
|
|
774
691
|
}
|
|
775
|
-
}
|
|
776
692
|
}
|
|
777
|
-
|
|
778
693
|
/**
|
|
779
694
|
* CLI Command Handler
|
|
780
|
-
*/
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
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
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
case 'validate':
|
|
853
|
-
// Validate current performance
|
|
854
|
-
await pipeline.initialize();
|
|
855
|
-
const metrics = await pipeline.captureMetrics();
|
|
856
|
-
console.log('\nš Current Performance:');
|
|
857
|
-
console.log(` Success Rate: ${(metrics.successRate * 100).toFixed(1)}%`);
|
|
858
|
-
console.log(` Avg Execution Time: ${metrics.executionTime.toFixed(0)}ms`);
|
|
859
|
-
console.log(` Average Score: ${metrics.score.toFixed(2)}`);
|
|
860
|
-
break;
|
|
861
|
-
|
|
862
|
-
default:
|
|
863
|
-
console.log('Usage: train-pipeline <command> [options]');
|
|
864
|
-
console.log('\nCommands:');
|
|
865
|
-
console.log(' run - Run training pipeline with real code');
|
|
866
|
-
console.log(' status - Show pipeline status');
|
|
867
|
-
console.log(' validate - Check current performance');
|
|
868
|
-
console.log('\nOptions:');
|
|
869
|
-
console.log(' --complexity <level> - easy/medium/hard');
|
|
870
|
-
console.log(' --iterations <n> - Training cycles');
|
|
871
|
-
}
|
|
695
|
+
*/ export async function trainingPipelineCommand(args, flags) {
|
|
696
|
+
const pipeline = new TrainingPipeline();
|
|
697
|
+
const subcommand = args[0] || 'run';
|
|
698
|
+
switch(subcommand){
|
|
699
|
+
case 'run':
|
|
700
|
+
// Run real pipeline
|
|
701
|
+
const options = {
|
|
702
|
+
complexity: flags.complexity || 'medium',
|
|
703
|
+
iterations: parseInt(flags.iterations) || 3,
|
|
704
|
+
validate: flags.validate !== false
|
|
705
|
+
};
|
|
706
|
+
console.log('š Starting Training Pipeline');
|
|
707
|
+
console.log(` Complexity: ${options.complexity}`);
|
|
708
|
+
console.log(` Iterations: ${options.iterations}`);
|
|
709
|
+
console.log(` Validation: ${options.validate ? 'Enabled' : 'Disabled'}`);
|
|
710
|
+
const result = await pipeline.runFullPipeline(options);
|
|
711
|
+
if (result.success) {
|
|
712
|
+
console.log('\nā
Training Pipeline completed');
|
|
713
|
+
console.log(` Total tasks: ${result.totalTasks}`);
|
|
714
|
+
console.log(` Real executions: ${result.realExecutions}`);
|
|
715
|
+
if (result.improvements) {
|
|
716
|
+
console.log('\nš Improvements:');
|
|
717
|
+
console.log(` Success Rate: ${result.improvements.successRate > 0 ? '+' : ''}${result.improvements.successRate.toFixed(1)}%`);
|
|
718
|
+
console.log(` Execution Time: ${result.improvements.executionTime > 0 ? '+' : ''}${result.improvements.executionTime.toFixed(1)}%`);
|
|
719
|
+
console.log(` Score: ${result.improvements.score > 0 ? '+' : ''}${result.improvements.score.toFixed(1)}%`);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
break;
|
|
723
|
+
case 'status':
|
|
724
|
+
// Show real pipeline status
|
|
725
|
+
await pipeline.initialize();
|
|
726
|
+
let profiles = {};
|
|
727
|
+
try {
|
|
728
|
+
const data = await fs.readFile(pipeline.agentProfiles, 'utf8');
|
|
729
|
+
profiles = JSON.parse(data);
|
|
730
|
+
} catch {
|
|
731
|
+
profiles = pipeline.getDefaultProfiles();
|
|
732
|
+
}
|
|
733
|
+
console.log('\nš Training Pipeline Status');
|
|
734
|
+
console.log('ā'.repeat(50));
|
|
735
|
+
console.log('\nš¤ Strategy Profiles:');
|
|
736
|
+
for (const [strategy, profile] of Object.entries(profiles)){
|
|
737
|
+
console.log(` ${strategy}:`);
|
|
738
|
+
console.log(` Success Rate: ${(profile.successRate * 100).toFixed(1)}%`);
|
|
739
|
+
console.log(` Average Score: ${profile.avgScore.toFixed(2)}`);
|
|
740
|
+
console.log(` Execution Time: ${profile.avgExecutionTime.toFixed(0)}ms`);
|
|
741
|
+
console.log(` Total Uses: ${profile.uses}`);
|
|
742
|
+
console.log(` Real Executions: ${profile.realExecutions || 0}`);
|
|
743
|
+
if (profile.improving !== undefined) {
|
|
744
|
+
console.log(` Trend: ${profile.improving ? 'š Improving' : 'š Declining'} (${profile.improvementRate}%)`);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
break;
|
|
748
|
+
case 'validate':
|
|
749
|
+
// Validate current performance
|
|
750
|
+
await pipeline.initialize();
|
|
751
|
+
const metrics = await pipeline.captureMetrics();
|
|
752
|
+
console.log('\nš Current Performance:');
|
|
753
|
+
console.log(` Success Rate: ${(metrics.successRate * 100).toFixed(1)}%`);
|
|
754
|
+
console.log(` Avg Execution Time: ${metrics.executionTime.toFixed(0)}ms`);
|
|
755
|
+
console.log(` Average Score: ${metrics.score.toFixed(2)}`);
|
|
756
|
+
break;
|
|
757
|
+
default:
|
|
758
|
+
console.log('Usage: train-pipeline <command> [options]');
|
|
759
|
+
console.log('\nCommands:');
|
|
760
|
+
console.log(' run - Run training pipeline with real code');
|
|
761
|
+
console.log(' status - Show pipeline status');
|
|
762
|
+
console.log(' validate - Check current performance');
|
|
763
|
+
console.log('\nOptions:');
|
|
764
|
+
console.log(' --complexity <level> - easy/medium/hard');
|
|
765
|
+
console.log(' --iterations <n> - Training cycles');
|
|
766
|
+
}
|
|
872
767
|
}
|
|
873
|
-
|
|
874
768
|
export default TrainingPipeline;
|