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
|
@@ -1,707 +1,584 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pair Programming with Recursive Auto-Fix Stream Chaining
|
|
3
3
|
* Automatically fixes and improves code until verification threshold is met
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { promisify } from 'util';
|
|
10
|
-
import readline from 'readline';
|
|
11
|
-
|
|
4
|
+
*/ import fs from "node:fs/promises";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { spawn, exec } from "child_process";
|
|
7
|
+
import { promisify } from "util";
|
|
8
|
+
import readline from "readline";
|
|
12
9
|
const execAsync = promisify(exec);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.fixHistory = [];
|
|
29
|
-
this.currentIteration = 0;
|
|
30
|
-
this.rl = null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async start() {
|
|
34
|
-
await this.saveSession();
|
|
35
|
-
this.showWelcome();
|
|
36
|
-
|
|
37
|
-
if (this.verify && this.autoFix) {
|
|
38
|
-
console.log('\n🔄 Auto-Fix Mode Enabled');
|
|
39
|
-
console.log(' • Will automatically fix issues until threshold is met');
|
|
40
|
-
console.log(` • Maximum iterations: ${this.maxIterations}`);
|
|
41
|
-
console.log(` • Target threshold: ${this.threshold}`);
|
|
42
|
-
|
|
43
|
-
// Start the recursive fix loop
|
|
44
|
-
await this.recursiveFixLoop();
|
|
45
|
-
} else if (this.verify) {
|
|
46
|
-
await this.runVerification();
|
|
10
|
+
let AutoFixPairSession = class AutoFixPairSession {
|
|
11
|
+
async start() {
|
|
12
|
+
await this.saveSession();
|
|
13
|
+
this.showWelcome();
|
|
14
|
+
if (this.verify && this.autoFix) {
|
|
15
|
+
console.log('\n🔄 Auto-Fix Mode Enabled');
|
|
16
|
+
console.log(' • Will automatically fix issues until threshold is met');
|
|
17
|
+
console.log(` • Maximum iterations: ${this.maxIterations}`);
|
|
18
|
+
console.log(` • Target threshold: ${this.threshold}`);
|
|
19
|
+
// Start the recursive fix loop
|
|
20
|
+
await this.recursiveFixLoop();
|
|
21
|
+
} else if (this.verify) {
|
|
22
|
+
await this.runVerification();
|
|
23
|
+
}
|
|
24
|
+
await this.startInteractiveMode();
|
|
47
25
|
}
|
|
48
|
-
|
|
49
|
-
await this.startInteractiveMode();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
26
|
+
/**
|
|
53
27
|
* Recursive stream-chaining loop that fixes issues until threshold is met
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (score < this.threshold) {
|
|
91
|
-
console.log(`\n⚠️ Max iterations reached. Final score: ${score.toFixed(2)}`);
|
|
92
|
-
console.log('💡 Manual intervention may be required.');
|
|
93
|
-
} else {
|
|
94
|
-
console.log(`\n🎉 Success! All issues fixed. Final score: ${score.toFixed(2)}`);
|
|
28
|
+
*/ async recursiveFixLoop() {
|
|
29
|
+
console.log('\n🚀 Starting Recursive Auto-Fix Loop...');
|
|
30
|
+
console.log('━'.repeat(50));
|
|
31
|
+
let score = 0;
|
|
32
|
+
this.currentIteration = 0;
|
|
33
|
+
while(score < this.threshold && this.currentIteration < this.maxIterations){
|
|
34
|
+
this.currentIteration++;
|
|
35
|
+
console.log(`\n📍 Iteration ${this.currentIteration}/${this.maxIterations}`);
|
|
36
|
+
// Step 1: Run verification
|
|
37
|
+
const verificationResult = await this.runVerification();
|
|
38
|
+
score = verificationResult.score;
|
|
39
|
+
if (score >= this.threshold) {
|
|
40
|
+
console.log(`\n✨ Threshold met! Score: ${score.toFixed(2)} >= ${this.threshold}`);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
// Step 2: Identify issues
|
|
44
|
+
const issues = this.identifyIssues(verificationResult);
|
|
45
|
+
console.log(`\n🔍 Issues found: ${issues.length}`);
|
|
46
|
+
issues.forEach((issue)=>console.log(` • ${issue.type}: ${issue.description}`));
|
|
47
|
+
// Step 3: Create fix chain
|
|
48
|
+
if (issues.length > 0) {
|
|
49
|
+
console.log('\n🔗 Creating stream-chain to fix issues...');
|
|
50
|
+
await this.createFixChain(issues);
|
|
51
|
+
}
|
|
52
|
+
// Step 4: Wait a bit before next iteration
|
|
53
|
+
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
54
|
+
}
|
|
55
|
+
if (score < this.threshold) {
|
|
56
|
+
console.log(`\n⚠️ Max iterations reached. Final score: ${score.toFixed(2)}`);
|
|
57
|
+
console.log('💡 Manual intervention may be required.');
|
|
58
|
+
} else {
|
|
59
|
+
console.log(`\n🎉 Success! All issues fixed. Final score: ${score.toFixed(2)}`);
|
|
60
|
+
}
|
|
61
|
+
// Show fix history
|
|
62
|
+
this.showFixHistory();
|
|
95
63
|
}
|
|
96
|
-
|
|
97
|
-
// Show fix history
|
|
98
|
-
this.showFixHistory();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
64
|
+
/**
|
|
102
65
|
* Create a stream chain to fix identified issues
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (chainCommand) {
|
|
126
|
-
chains.push(chainCommand);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Execute fix chains
|
|
131
|
-
for (const chain of chains) {
|
|
132
|
-
console.log(` 🔧 Executing: ${chain.description}`);
|
|
133
|
-
await this.executeChain(chain);
|
|
134
|
-
|
|
135
|
-
// Record fix attempt
|
|
136
|
-
this.fixHistory.push({
|
|
137
|
-
iteration: this.currentIteration,
|
|
138
|
-
type: chain.type,
|
|
139
|
-
command: chain.command,
|
|
140
|
-
timestamp: new Date(),
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Create lint fix chain using stream-chaining
|
|
147
|
-
*/
|
|
148
|
-
createLintFixChain() {
|
|
149
|
-
return {
|
|
150
|
-
type: 'lint',
|
|
151
|
-
description: 'Auto-fix linting issues',
|
|
152
|
-
command: async () => {
|
|
153
|
-
console.log(' Running: npm run lint --fix');
|
|
154
|
-
|
|
155
|
-
// First, try auto-fix
|
|
156
|
-
try {
|
|
157
|
-
await execAsync('npm run lint -- --fix 2>&1 || true');
|
|
158
|
-
console.log(' ✅ Linting auto-fix applied');
|
|
159
|
-
} catch (error) {
|
|
160
|
-
console.log(' ⚠️ Some linting issues require manual fixes');
|
|
66
|
+
*/ async createFixChain(issues) {
|
|
67
|
+
const chains = [];
|
|
68
|
+
for (const issue of issues){
|
|
69
|
+
let chainCommand = null;
|
|
70
|
+
switch(issue.type){
|
|
71
|
+
case 'lint':
|
|
72
|
+
chainCommand = this.createLintFixChain();
|
|
73
|
+
break;
|
|
74
|
+
case 'typecheck':
|
|
75
|
+
chainCommand = this.createTypeFixChain();
|
|
76
|
+
break;
|
|
77
|
+
case 'build':
|
|
78
|
+
chainCommand = this.createBuildFixChain();
|
|
79
|
+
break;
|
|
80
|
+
case 'test':
|
|
81
|
+
chainCommand = this.createTestFixChain();
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
if (chainCommand) {
|
|
85
|
+
chains.push(chainCommand);
|
|
86
|
+
}
|
|
161
87
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
88
|
+
// Execute fix chains
|
|
89
|
+
for (const chain of chains){
|
|
90
|
+
console.log(` 🔧 Executing: ${chain.description}`);
|
|
91
|
+
await this.executeChain(chain);
|
|
92
|
+
// Record fix attempt
|
|
93
|
+
this.fixHistory.push({
|
|
94
|
+
iteration: this.currentIteration,
|
|
95
|
+
type: chain.type,
|
|
96
|
+
command: chain.command,
|
|
97
|
+
timestamp: new Date()
|
|
98
|
+
});
|
|
168
99
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create lint fix chain using stream-chaining
|
|
103
|
+
*/ createLintFixChain() {
|
|
104
|
+
return {
|
|
105
|
+
type: 'lint',
|
|
106
|
+
description: 'Auto-fix linting issues',
|
|
107
|
+
command: async ()=>{
|
|
108
|
+
console.log(' Running: npm run lint --fix');
|
|
109
|
+
// First, try auto-fix
|
|
110
|
+
try {
|
|
111
|
+
await execAsync('npm run lint -- --fix 2>&1 || true');
|
|
112
|
+
console.log(' ✅ Linting auto-fix applied');
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.log(' ⚠️ Some linting issues require manual fixes');
|
|
115
|
+
}
|
|
116
|
+
// If complex issues remain, use Claude stream chain
|
|
117
|
+
const { stdout: lintOutput } = await execAsync('npm run lint 2>&1 || true');
|
|
118
|
+
if (lintOutput.includes('error')) {
|
|
119
|
+
console.log(' 🤖 Using Claude to fix remaining issues...');
|
|
120
|
+
await this.executeClaudeFixChain('lint', lintOutput);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
174
126
|
* Create TypeScript fix chain
|
|
175
|
-
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
127
|
+
*/ createTypeFixChain() {
|
|
128
|
+
return {
|
|
129
|
+
type: 'typecheck',
|
|
130
|
+
description: 'Fix TypeScript errors',
|
|
131
|
+
command: async ()=>{
|
|
132
|
+
console.log(' Analyzing TypeScript errors...');
|
|
133
|
+
// Get type errors
|
|
134
|
+
const { stdout: typeErrors } = await execAsync('npm run typecheck 2>&1 || true');
|
|
135
|
+
if (typeErrors.includes('error')) {
|
|
136
|
+
console.log(' 🤖 Using Claude to fix type errors...');
|
|
137
|
+
await this.executeClaudeFixChain('typescript', typeErrors);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
195
143
|
* Create build fix chain
|
|
196
|
-
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
144
|
+
*/ createBuildFixChain() {
|
|
145
|
+
return {
|
|
146
|
+
type: 'build',
|
|
147
|
+
description: 'Fix build errors',
|
|
148
|
+
command: async ()=>{
|
|
149
|
+
console.log(' Analyzing build errors...');
|
|
150
|
+
const { stdout: buildErrors } = await execAsync('npm run build 2>&1 || true');
|
|
151
|
+
if (buildErrors.includes('error')) {
|
|
152
|
+
console.log(' 🤖 Using Claude to fix build errors...');
|
|
153
|
+
await this.executeClaudeFixChain('build', buildErrors);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
215
159
|
* Create test fix chain
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
160
|
+
*/ createTestFixChain() {
|
|
161
|
+
return {
|
|
162
|
+
type: 'test',
|
|
163
|
+
description: 'Fix failing tests',
|
|
164
|
+
command: async ()=>{
|
|
165
|
+
console.log(' Analyzing test failures...');
|
|
166
|
+
const { stdout: testOutput } = await execAsync('npm test 2>&1 || true');
|
|
167
|
+
if (testOutput.includes('fail')) {
|
|
168
|
+
console.log(' 🤖 Using Claude to fix test failures...');
|
|
169
|
+
await this.executeClaudeFixChain('test', testOutput);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
235
175
|
* Execute Claude stream chain to fix specific issues
|
|
236
|
-
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
/**
|
|
176
|
+
*/ async executeClaudeFixChain(type, errorOutput) {
|
|
177
|
+
const prompts = {
|
|
178
|
+
lint: `Fix these ESLint errors. Output only the corrected code:\n\n${errorOutput}`,
|
|
179
|
+
typescript: `Fix these TypeScript errors. Output only the corrected code:\n\n${errorOutput}`,
|
|
180
|
+
build: `Fix these build errors. Output only the corrected code:\n\n${errorOutput}`,
|
|
181
|
+
test: `Fix these test failures. Output only the corrected code:\n\n${errorOutput}`
|
|
182
|
+
};
|
|
183
|
+
return new Promise((resolve, reject)=>{
|
|
184
|
+
// Create stream chain using Claude
|
|
185
|
+
const claude = spawn('claude', [
|
|
186
|
+
'-p',
|
|
187
|
+
'--output-format',
|
|
188
|
+
'stream-json',
|
|
189
|
+
prompts[type]
|
|
190
|
+
]);
|
|
191
|
+
let output = '';
|
|
192
|
+
claude.stdout.on('data', (data)=>{
|
|
193
|
+
output += data.toString();
|
|
194
|
+
});
|
|
195
|
+
claude.on('close', (code)=>{
|
|
196
|
+
if (code === 0) {
|
|
197
|
+
// Parse and apply fixes
|
|
198
|
+
this.applyClaudeFixes(type, output);
|
|
199
|
+
resolve();
|
|
200
|
+
} else {
|
|
201
|
+
reject(new Error(`Claude fix chain failed with code ${code}`));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
claude.on('error', (error)=>{
|
|
205
|
+
console.error(' ❌ Claude chain error:', error.message);
|
|
206
|
+
reject(error);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
273
211
|
* Apply fixes suggested by Claude
|
|
274
|
-
*/
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
212
|
+
*/ async applyClaudeFixes(type, streamOutput) {
|
|
213
|
+
try {
|
|
214
|
+
// Extract content from stream-json output
|
|
215
|
+
const fixes = this.extractFixesFromStream(streamOutput);
|
|
216
|
+
if (fixes && fixes.length > 0) {
|
|
217
|
+
console.log(` 📝 Applying ${fixes.length} fixes...`);
|
|
218
|
+
// Apply each fix (simplified - in production would need file mapping)
|
|
219
|
+
for (const fix of fixes){
|
|
220
|
+
// This is simplified - real implementation would parse and apply fixes
|
|
221
|
+
console.log(` • Fixed: ${fix.file || type}`);
|
|
222
|
+
}
|
|
223
|
+
console.log(' ✅ Fixes applied successfully');
|
|
224
|
+
}
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.error(' ⚠️ Could not apply all fixes:', error.message);
|
|
287
227
|
}
|
|
288
|
-
|
|
289
|
-
console.log(' ✅ Fixes applied successfully');
|
|
290
|
-
}
|
|
291
|
-
} catch (error) {
|
|
292
|
-
console.error(' ⚠️ Could not apply all fixes:', error.message);
|
|
293
228
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
/**
|
|
229
|
+
/**
|
|
297
230
|
* Extract fixes from Claude's stream-json output
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
231
|
+
*/ extractFixesFromStream(streamOutput) {
|
|
232
|
+
const fixes = [];
|
|
233
|
+
const lines = streamOutput.split('\n').filter((line)=>line.trim());
|
|
234
|
+
for (const line of lines){
|
|
235
|
+
try {
|
|
236
|
+
const json = JSON.parse(line);
|
|
237
|
+
// Look for code fixes in the stream
|
|
238
|
+
if (json.type === 'message' && json.message && json.message.content) {
|
|
239
|
+
for (const item of json.message.content){
|
|
240
|
+
if (item.type === 'text' && item.text) {
|
|
241
|
+
// Parse for code blocks or fix instructions
|
|
242
|
+
const codeMatch = item.text.match(/```[\w]*\n([\s\S]*?)```/g);
|
|
243
|
+
if (codeMatch) {
|
|
244
|
+
fixes.push({
|
|
245
|
+
type: 'code',
|
|
246
|
+
content: codeMatch[0].replace(/```[\w]*\n|```/g, '')
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
} catch (e) {
|
|
253
|
+
// Skip non-JSON lines
|
|
319
254
|
}
|
|
320
|
-
}
|
|
321
255
|
}
|
|
322
|
-
|
|
323
|
-
// Skip non-JSON lines
|
|
324
|
-
}
|
|
256
|
+
return fixes;
|
|
325
257
|
}
|
|
326
|
-
|
|
327
|
-
return fixes;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
258
|
+
/**
|
|
331
259
|
* Execute a fix chain command
|
|
332
|
-
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
260
|
+
*/ async executeChain(chain) {
|
|
261
|
+
try {
|
|
262
|
+
await chain.command();
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.error(` ❌ Fix failed: ${error.message}`);
|
|
265
|
+
}
|
|
338
266
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
/**
|
|
267
|
+
/**
|
|
342
268
|
* Identify issues from verification results
|
|
343
|
-
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
269
|
+
*/ identifyIssues(verificationResult) {
|
|
270
|
+
const issues = [];
|
|
271
|
+
if (verificationResult.results) {
|
|
272
|
+
for (const check of verificationResult.results){
|
|
273
|
+
if (check.score < 0.8) {
|
|
274
|
+
issues.push({
|
|
275
|
+
type: check.name.toLowerCase().replace(' check', '').replace(' ', ''),
|
|
276
|
+
description: `Score: ${check.score.toFixed(2)}`,
|
|
277
|
+
severity: check.score < 0.5 ? 'high' : 'medium'
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
355
281
|
}
|
|
356
|
-
|
|
282
|
+
return issues;
|
|
357
283
|
}
|
|
358
|
-
|
|
359
|
-
return issues;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
284
|
+
/**
|
|
363
285
|
* Run verification and return detailed results
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
286
|
+
*/ async runVerification() {
|
|
287
|
+
console.log('\n🔍 Running verification check...');
|
|
288
|
+
const checks = [
|
|
289
|
+
{
|
|
290
|
+
name: 'Type Check',
|
|
291
|
+
command: 'npm run typecheck 2>&1 || true',
|
|
292
|
+
weight: 0.4
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: 'Linting',
|
|
296
|
+
command: 'npm run lint 2>&1 || true',
|
|
297
|
+
weight: 0.3
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'Build',
|
|
301
|
+
command: 'npm run build 2>&1 || true',
|
|
302
|
+
weight: 0.3
|
|
303
|
+
}
|
|
304
|
+
];
|
|
305
|
+
const results = [];
|
|
306
|
+
let totalScore = 0;
|
|
307
|
+
let totalWeight = 0;
|
|
308
|
+
for (const check of checks){
|
|
309
|
+
try {
|
|
310
|
+
const { stdout, stderr } = await execAsync(check.command);
|
|
311
|
+
const output = stdout + stderr;
|
|
312
|
+
let score = 1.0;
|
|
313
|
+
if (output.toLowerCase().includes('error')) {
|
|
314
|
+
const errorCount = (output.match(/error/gi) || []).length;
|
|
315
|
+
score = Math.max(0.2, 1.0 - errorCount * 0.1);
|
|
316
|
+
} else if (output.toLowerCase().includes('warning')) {
|
|
317
|
+
const warningCount = (output.match(/warning/gi) || []).length;
|
|
318
|
+
score = Math.max(0.7, 1.0 - warningCount * 0.05);
|
|
319
|
+
}
|
|
320
|
+
totalScore += score * check.weight;
|
|
321
|
+
totalWeight += check.weight;
|
|
322
|
+
const icon = score >= 0.8 ? '✅' : score >= 0.5 ? '⚠️' : '❌';
|
|
323
|
+
console.log(` ${icon} ${check.name}: ${score.toFixed(2)}`);
|
|
324
|
+
results.push({
|
|
325
|
+
name: check.name,
|
|
326
|
+
score,
|
|
327
|
+
output: output.slice(0, 200),
|
|
328
|
+
errors: (output.match(/error/gi) || []).length,
|
|
329
|
+
warnings: (output.match(/warning/gi) || []).length
|
|
330
|
+
});
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.log(` ❌ ${check.name}: 0.00 (failed)`);
|
|
333
|
+
results.push({
|
|
334
|
+
name: check.name,
|
|
335
|
+
score: 0,
|
|
336
|
+
error: error.message
|
|
337
|
+
});
|
|
338
|
+
totalWeight += check.weight;
|
|
339
|
+
}
|
|
402
340
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
output: output.slice(0, 200),
|
|
414
|
-
errors: (output.match(/error/gi) || []).length,
|
|
415
|
-
warnings: (output.match(/warning/gi) || []).length,
|
|
416
|
-
});
|
|
417
|
-
} catch (error) {
|
|
418
|
-
console.log(` ❌ ${check.name}: 0.00 (failed)`);
|
|
419
|
-
results.push({ name: check.name, score: 0, error: error.message });
|
|
420
|
-
totalWeight += check.weight;
|
|
421
|
-
}
|
|
341
|
+
const averageScore = totalWeight > 0 ? totalScore / totalWeight : 0;
|
|
342
|
+
console.log(`\n📊 Verification Score: ${averageScore.toFixed(2)}/${this.threshold}`);
|
|
343
|
+
const verificationResult = {
|
|
344
|
+
score: averageScore,
|
|
345
|
+
results,
|
|
346
|
+
timestamp: new Date(),
|
|
347
|
+
iteration: this.currentIteration
|
|
348
|
+
};
|
|
349
|
+
this.verificationScores.push(verificationResult);
|
|
350
|
+
return verificationResult;
|
|
422
351
|
}
|
|
423
|
-
|
|
424
|
-
const averageScore = totalWeight > 0 ? totalScore / totalWeight : 0;
|
|
425
|
-
|
|
426
|
-
console.log(`\n📊 Verification Score: ${averageScore.toFixed(2)}/${this.threshold}`);
|
|
427
|
-
|
|
428
|
-
const verificationResult = {
|
|
429
|
-
score: averageScore,
|
|
430
|
-
results,
|
|
431
|
-
timestamp: new Date(),
|
|
432
|
-
iteration: this.currentIteration,
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
this.verificationScores.push(verificationResult);
|
|
436
|
-
|
|
437
|
-
return verificationResult;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
352
|
+
/**
|
|
441
353
|
* Show fix history
|
|
442
|
-
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
console.log('━'.repeat(50));
|
|
455
|
-
console.log(` Total fixes applied: ${this.fixHistory.length}`);
|
|
456
|
-
console.log(` Final iterations: ${this.currentIteration}`);
|
|
354
|
+
*/ showFixHistory() {
|
|
355
|
+
if (this.fixHistory.length > 0) {
|
|
356
|
+
console.log('\n📋 Fix History:');
|
|
357
|
+
console.log('━'.repeat(50));
|
|
358
|
+
for (const fix of this.fixHistory){
|
|
359
|
+
console.log(` Iteration ${fix.iteration}: Fixed ${fix.type} at ${fix.timestamp.toLocaleTimeString()}`);
|
|
360
|
+
}
|
|
361
|
+
console.log('━'.repeat(50));
|
|
362
|
+
console.log(` Total fixes applied: ${this.fixHistory.length}`);
|
|
363
|
+
console.log(` Final iterations: ${this.currentIteration}`);
|
|
364
|
+
}
|
|
457
365
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
console.log(` • Stream chaining: Enabled`);
|
|
366
|
+
showWelcome() {
|
|
367
|
+
console.log('\n🚀 Starting Pair Programming Session');
|
|
368
|
+
console.log('━'.repeat(50));
|
|
369
|
+
console.log(`Session ID: ${this.sessionId}`);
|
|
370
|
+
console.log(`Mode: ${this.mode}`);
|
|
371
|
+
console.log(`Verification: ${this.verify ? '✅ Enabled' : '❌ Disabled'}`);
|
|
372
|
+
console.log(`Auto-Fix: ${this.autoFix ? '✅ Enabled' : '❌ Disabled'}`);
|
|
373
|
+
console.log(`Testing: ${this.test ? '✅ Enabled' : '❌ Disabled'}`);
|
|
374
|
+
if (this.autoFix) {
|
|
375
|
+
console.log(`\n🔄 Recursive Auto-Fix Settings:`);
|
|
376
|
+
console.log(` • Target threshold: ${this.threshold}`);
|
|
377
|
+
console.log(` • Max iterations: ${this.maxIterations}`);
|
|
378
|
+
console.log(` • Stream chaining: Enabled`);
|
|
379
|
+
}
|
|
380
|
+
console.log('━'.repeat(50));
|
|
474
381
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
output: process.stdout,
|
|
483
|
-
prompt: '\n💻 pair> ',
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
console.log('\n💡 Interactive mode active. Type /help for commands.\n');
|
|
487
|
-
|
|
488
|
-
this.showCommands();
|
|
489
|
-
this.rl.prompt();
|
|
490
|
-
|
|
491
|
-
this.rl.on('line', async (line) => {
|
|
492
|
-
const input = line.trim();
|
|
493
|
-
|
|
494
|
-
if (input.startsWith('/')) {
|
|
495
|
-
await this.handleCommand(input);
|
|
496
|
-
} else if (input) {
|
|
497
|
-
console.log('🤖 AI: Processing your input...');
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
this.rl.prompt();
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
this.rl.on('close', () => {
|
|
504
|
-
this.end();
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
showCommands() {
|
|
509
|
-
console.log('\n📝 Session Commands:');
|
|
510
|
-
console.log(' /help - Show available commands');
|
|
511
|
-
console.log(' /verify - Run verification check');
|
|
512
|
-
console.log(' /autofix - Start recursive auto-fix');
|
|
513
|
-
console.log(' /status - Show session status');
|
|
514
|
-
console.log(' /metrics - Show quality metrics');
|
|
515
|
-
console.log(' /history - Show fix history');
|
|
516
|
-
console.log(' /test - Run tests');
|
|
517
|
-
console.log(' /commit - Commit with verification');
|
|
518
|
-
console.log(' /end - End session');
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
async handleCommand(command) {
|
|
522
|
-
const [cmd] = command.split(' ');
|
|
523
|
-
|
|
524
|
-
switch (cmd) {
|
|
525
|
-
case '/help':
|
|
382
|
+
async startInteractiveMode() {
|
|
383
|
+
this.rl = readline.createInterface({
|
|
384
|
+
input: process.stdin,
|
|
385
|
+
output: process.stdout,
|
|
386
|
+
prompt: '\n💻 pair> '
|
|
387
|
+
});
|
|
388
|
+
console.log('\n💡 Interactive mode active. Type /help for commands.\n');
|
|
526
389
|
this.showCommands();
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
case '/metrics':
|
|
542
|
-
this.showMetrics();
|
|
543
|
-
break;
|
|
544
|
-
|
|
545
|
-
case '/history':
|
|
546
|
-
this.showFixHistory();
|
|
547
|
-
break;
|
|
548
|
-
|
|
549
|
-
case '/test':
|
|
550
|
-
await this.runTests();
|
|
551
|
-
break;
|
|
552
|
-
|
|
553
|
-
case '/commit':
|
|
554
|
-
await this.commitWithVerification();
|
|
555
|
-
break;
|
|
556
|
-
|
|
557
|
-
case '/end':
|
|
558
|
-
case '/exit':
|
|
559
|
-
await this.end();
|
|
560
|
-
process.exit(0);
|
|
561
|
-
break;
|
|
562
|
-
|
|
563
|
-
default:
|
|
564
|
-
console.log(`❌ Unknown command: ${cmd}`);
|
|
565
|
-
console.log('💡 Type /help for available commands');
|
|
390
|
+
this.rl.prompt();
|
|
391
|
+
this.rl.on('line', async (line)=>{
|
|
392
|
+
const input = line.trim();
|
|
393
|
+
if (input.startsWith('/')) {
|
|
394
|
+
await this.handleCommand(input);
|
|
395
|
+
} else if (input) {
|
|
396
|
+
console.log('🤖 AI: Processing your input...');
|
|
397
|
+
}
|
|
398
|
+
this.rl.prompt();
|
|
399
|
+
});
|
|
400
|
+
this.rl.on('close', ()=>{
|
|
401
|
+
this.end();
|
|
402
|
+
});
|
|
566
403
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
console.log(`Fixes Applied: ${this.fixHistory.length}`);
|
|
579
|
-
|
|
580
|
-
if (this.verificationScores.length > 0) {
|
|
581
|
-
const latest = this.verificationScores[this.verificationScores.length - 1];
|
|
582
|
-
console.log(`Latest Score: ${latest.score.toFixed(2)}`);
|
|
404
|
+
showCommands() {
|
|
405
|
+
console.log('\n📝 Session Commands:');
|
|
406
|
+
console.log(' /help - Show available commands');
|
|
407
|
+
console.log(' /verify - Run verification check');
|
|
408
|
+
console.log(' /autofix - Start recursive auto-fix');
|
|
409
|
+
console.log(' /status - Show session status');
|
|
410
|
+
console.log(' /metrics - Show quality metrics');
|
|
411
|
+
console.log(' /history - Show fix history');
|
|
412
|
+
console.log(' /test - Run tests');
|
|
413
|
+
console.log(' /commit - Commit with verification');
|
|
414
|
+
console.log(' /end - End session');
|
|
583
415
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
416
|
+
async handleCommand(command) {
|
|
417
|
+
const [cmd] = command.split(' ');
|
|
418
|
+
switch(cmd){
|
|
419
|
+
case '/help':
|
|
420
|
+
this.showCommands();
|
|
421
|
+
break;
|
|
422
|
+
case '/verify':
|
|
423
|
+
await this.runVerification();
|
|
424
|
+
break;
|
|
425
|
+
case '/autofix':
|
|
426
|
+
await this.recursiveFixLoop();
|
|
427
|
+
break;
|
|
428
|
+
case '/status':
|
|
429
|
+
await this.showStatus();
|
|
430
|
+
break;
|
|
431
|
+
case '/metrics':
|
|
432
|
+
this.showMetrics();
|
|
433
|
+
break;
|
|
434
|
+
case '/history':
|
|
435
|
+
this.showFixHistory();
|
|
436
|
+
break;
|
|
437
|
+
case '/test':
|
|
438
|
+
await this.runTests();
|
|
439
|
+
break;
|
|
440
|
+
case '/commit':
|
|
441
|
+
await this.commitWithVerification();
|
|
442
|
+
break;
|
|
443
|
+
case '/end':
|
|
444
|
+
case '/exit':
|
|
445
|
+
await this.end();
|
|
446
|
+
process.exit(0);
|
|
447
|
+
break;
|
|
448
|
+
default:
|
|
449
|
+
console.log(`❌ Unknown command: ${cmd}`);
|
|
450
|
+
console.log('💡 Type /help for available commands');
|
|
451
|
+
}
|
|
604
452
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
453
|
+
async showStatus() {
|
|
454
|
+
const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
|
|
455
|
+
console.log('\n📊 Session Status');
|
|
456
|
+
console.log('━'.repeat(40));
|
|
457
|
+
console.log(`Session ID: ${this.sessionId}`);
|
|
458
|
+
console.log(`Duration: ${duration} minutes`);
|
|
459
|
+
console.log(`Auto-Fix: ${this.autoFix ? 'Enabled' : 'Disabled'}`);
|
|
460
|
+
console.log(`Fix Iterations: ${this.currentIteration}`);
|
|
461
|
+
console.log(`Fixes Applied: ${this.fixHistory.length}`);
|
|
462
|
+
if (this.verificationScores.length > 0) {
|
|
463
|
+
const latest = this.verificationScores[this.verificationScores.length - 1];
|
|
464
|
+
console.log(`Latest Score: ${latest.score.toFixed(2)}`);
|
|
465
|
+
}
|
|
617
466
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
467
|
+
showMetrics() {
|
|
468
|
+
console.log('\n📈 Quality Metrics');
|
|
469
|
+
console.log('━'.repeat(40));
|
|
470
|
+
if (this.verificationScores.length > 0) {
|
|
471
|
+
console.log('\nScore Progression:');
|
|
472
|
+
this.verificationScores.forEach((v, i)=>{
|
|
473
|
+
const bar = '█'.repeat(Math.floor(v.score * 20));
|
|
474
|
+
console.log(` ${i + 1}. ${bar} ${v.score.toFixed(2)}`);
|
|
475
|
+
});
|
|
476
|
+
// Show improvement
|
|
477
|
+
if (this.verificationScores.length > 1) {
|
|
478
|
+
const first = this.verificationScores[0].score;
|
|
479
|
+
const last = this.verificationScores[this.verificationScores.length - 1].score;
|
|
480
|
+
const improvement = ((last - first) * 100).toFixed(1);
|
|
481
|
+
console.log(`\n Improvement: +${improvement}%`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
628
484
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
console.log('\n✨ Session Complete!');
|
|
641
|
-
console.log('━'.repeat(40));
|
|
642
|
-
console.log(`Duration: ${duration} minutes`);
|
|
643
|
-
console.log(`Total Fixes: ${this.fixHistory.length}`);
|
|
644
|
-
console.log(`Final Iterations: ${this.currentIteration}`);
|
|
645
|
-
|
|
646
|
-
if (this.verificationScores.length > 0) {
|
|
647
|
-
const final = this.verificationScores[this.verificationScores.length - 1];
|
|
648
|
-
console.log(`Final Score: ${final.score.toFixed(2)}`);
|
|
485
|
+
async runTests() {
|
|
486
|
+
console.log('\n🧪 Running tests...');
|
|
487
|
+
try {
|
|
488
|
+
const { stdout } = await execAsync('npm test 2>&1 || true');
|
|
489
|
+
const passed = stdout.includes('PASS');
|
|
490
|
+
console.log(` ${passed ? '✅' : '❌'} Tests ${passed ? 'passed' : 'failed'}`);
|
|
491
|
+
return passed;
|
|
492
|
+
} catch (error) {
|
|
493
|
+
console.log(' ❌ Test execution failed:', error.message);
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
649
496
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
497
|
+
async commitWithVerification() {
|
|
498
|
+
const result = await this.runVerification();
|
|
499
|
+
if (result.score >= this.threshold) {
|
|
500
|
+
console.log('✅ Verification passed! Ready to commit.');
|
|
501
|
+
} else {
|
|
502
|
+
console.log('❌ Verification failed!');
|
|
503
|
+
console.log('💡 Run /autofix to automatically fix issues');
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async end() {
|
|
507
|
+
console.log('\n🛑 Ending pair programming session...');
|
|
508
|
+
if (this.rl) this.rl.close();
|
|
509
|
+
this.status = 'completed';
|
|
510
|
+
await this.saveSession();
|
|
511
|
+
const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
|
|
512
|
+
console.log('\n✨ Session Complete!');
|
|
513
|
+
console.log('━'.repeat(40));
|
|
514
|
+
console.log(`Duration: ${duration} minutes`);
|
|
515
|
+
console.log(`Total Fixes: ${this.fixHistory.length}`);
|
|
516
|
+
console.log(`Final Iterations: ${this.currentIteration}`);
|
|
517
|
+
if (this.verificationScores.length > 0) {
|
|
518
|
+
const final = this.verificationScores[this.verificationScores.length - 1];
|
|
519
|
+
console.log(`Final Score: ${final.score.toFixed(2)}`);
|
|
520
|
+
}
|
|
521
|
+
console.log('\n👋 Thanks for pair programming!\n');
|
|
522
|
+
}
|
|
523
|
+
async saveSession() {
|
|
524
|
+
const sessionPath = '.claude-flow/sessions/pair';
|
|
525
|
+
await fs.mkdir(sessionPath, {
|
|
526
|
+
recursive: true
|
|
527
|
+
});
|
|
528
|
+
const sessionData = {
|
|
529
|
+
id: this.sessionId,
|
|
530
|
+
mode: this.mode,
|
|
531
|
+
verify: this.verify,
|
|
532
|
+
autoFix: this.autoFix,
|
|
533
|
+
threshold: this.threshold,
|
|
534
|
+
startTime: this.startTime.toISOString(),
|
|
535
|
+
status: this.status,
|
|
536
|
+
verificationScores: this.verificationScores,
|
|
537
|
+
fixHistory: this.fixHistory,
|
|
538
|
+
iterations: this.currentIteration
|
|
539
|
+
};
|
|
540
|
+
await fs.writeFile(path.join(sessionPath, `${this.sessionId}.json`), JSON.stringify(sessionData, null, 2));
|
|
541
|
+
}
|
|
542
|
+
constructor(options = {}){
|
|
543
|
+
this.sessionId = `pair_${Date.now()}`;
|
|
544
|
+
this.mode = options.mode || 'switch';
|
|
545
|
+
this.agent = options.agent || 'auto';
|
|
546
|
+
this.verify = options.verify || false;
|
|
547
|
+
this.autoFix = options.autoFix || false; // New: Enable recursive auto-fix
|
|
548
|
+
this.test = options.test || false;
|
|
549
|
+
this.threshold = options.threshold || 0.95;
|
|
550
|
+
this.maxIterations = options.maxIterations || 5; // Max fix attempts
|
|
551
|
+
this.startTime = new Date();
|
|
552
|
+
this.status = 'active';
|
|
553
|
+
this.currentRole = 'driver';
|
|
554
|
+
this.verificationScores = [];
|
|
555
|
+
this.fixHistory = [];
|
|
556
|
+
this.currentIteration = 0;
|
|
557
|
+
this.rl = null;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
678
560
|
async function pairCommand(args = [], flags = {}) {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
561
|
+
console.log('\n👥 Pair Programming with Auto-Fix');
|
|
562
|
+
console.log('━'.repeat(50));
|
|
563
|
+
if (flags.help || args.includes('--help')) {
|
|
564
|
+
showHelp();
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (flags.start) {
|
|
568
|
+
const session = new AutoFixPairSession({
|
|
569
|
+
mode: flags.mode || 'switch',
|
|
570
|
+
verify: flags.verify || false,
|
|
571
|
+
autoFix: flags.autofix || flags.fix || false,
|
|
572
|
+
test: flags.test || false,
|
|
573
|
+
threshold: parseFloat(flags.threshold) || 0.95,
|
|
574
|
+
maxIterations: parseInt(flags.iterations) || 5
|
|
575
|
+
});
|
|
576
|
+
return await session.start();
|
|
577
|
+
}
|
|
683
578
|
showHelp();
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
if (flags.start) {
|
|
688
|
-
const session = new AutoFixPairSession({
|
|
689
|
-
mode: flags.mode || 'switch',
|
|
690
|
-
verify: flags.verify || false,
|
|
691
|
-
autoFix: flags.autofix || flags.fix || false,
|
|
692
|
-
test: flags.test || false,
|
|
693
|
-
threshold: parseFloat(flags.threshold) || 0.95,
|
|
694
|
-
maxIterations: parseInt(flags.iterations) || 5,
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
return await session.start();
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
showHelp();
|
|
701
579
|
}
|
|
702
|
-
|
|
703
580
|
function showHelp() {
|
|
704
|
-
|
|
581
|
+
console.log(`
|
|
705
582
|
📚 USAGE:
|
|
706
583
|
claude-flow-novice pair [options]
|
|
707
584
|
|
|
@@ -751,5 +628,4 @@ function showHelp() {
|
|
|
751
628
|
.claude/commands/pair/README.md
|
|
752
629
|
`);
|
|
753
630
|
}
|
|
754
|
-
|
|
755
631
|
export default pairCommand;
|