claude-flow-novice 1.3.0 โ 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/migration/README.md +434 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Pair Programming with Working Auto-Fix
|
|
3
|
+
* This version actually applies fixes using real commands
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { spawn, exec } from 'child_process';
|
|
9
|
+
import { promisify } from 'util';
|
|
10
|
+
import readline from 'readline';
|
|
11
|
+
|
|
12
|
+
const execAsync = promisify(exec);
|
|
13
|
+
|
|
14
|
+
// Guidance mode configurations
|
|
15
|
+
const GUIDANCE_MODES = {
|
|
16
|
+
beginner: {
|
|
17
|
+
verbosity: 'high',
|
|
18
|
+
suggestions: 'frequent',
|
|
19
|
+
explanations: 'detailed',
|
|
20
|
+
autoFix: true,
|
|
21
|
+
threshold: 0.9,
|
|
22
|
+
description: 'Detailed explanations and step-by-step guidance',
|
|
23
|
+
},
|
|
24
|
+
intermediate: {
|
|
25
|
+
verbosity: 'medium',
|
|
26
|
+
suggestions: 'balanced',
|
|
27
|
+
explanations: 'concise',
|
|
28
|
+
autoFix: true,
|
|
29
|
+
threshold: 0.95,
|
|
30
|
+
description: 'Balanced guidance with key explanations',
|
|
31
|
+
},
|
|
32
|
+
expert: {
|
|
33
|
+
verbosity: 'low',
|
|
34
|
+
suggestions: 'minimal',
|
|
35
|
+
explanations: 'brief',
|
|
36
|
+
autoFix: true,
|
|
37
|
+
threshold: 0.98,
|
|
38
|
+
description: 'Minimal guidance, maximum efficiency',
|
|
39
|
+
},
|
|
40
|
+
mentor: {
|
|
41
|
+
verbosity: 'high',
|
|
42
|
+
suggestions: 'educational',
|
|
43
|
+
explanations: 'teaching',
|
|
44
|
+
autoFix: false,
|
|
45
|
+
threshold: 0.9,
|
|
46
|
+
description: 'Educational focus with learning opportunities',
|
|
47
|
+
},
|
|
48
|
+
strict: {
|
|
49
|
+
verbosity: 'medium',
|
|
50
|
+
suggestions: 'quality-focused',
|
|
51
|
+
explanations: 'standards',
|
|
52
|
+
autoFix: true,
|
|
53
|
+
threshold: 0.99,
|
|
54
|
+
description: 'Enforces highest code quality standards',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
class WorkingPairSession {
|
|
59
|
+
constructor(options = {}) {
|
|
60
|
+
this.sessionId = `pair_${Date.now()}`;
|
|
61
|
+
this.guidanceMode = options.guidance || 'intermediate';
|
|
62
|
+
this.guidance = GUIDANCE_MODES[this.guidanceMode];
|
|
63
|
+
this.autoFix = options.autoFix ?? this.guidance.autoFix;
|
|
64
|
+
this.threshold = options.threshold || this.guidance.threshold;
|
|
65
|
+
this.maxIterations = options.maxIterations || 5;
|
|
66
|
+
this.verify = options.verify || false;
|
|
67
|
+
this.startTime = new Date();
|
|
68
|
+
this.status = 'active';
|
|
69
|
+
this.verificationScores = [];
|
|
70
|
+
this.fixHistory = [];
|
|
71
|
+
this.currentIteration = 0;
|
|
72
|
+
this.rl = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async start() {
|
|
76
|
+
await this.saveSession();
|
|
77
|
+
this.showWelcome();
|
|
78
|
+
|
|
79
|
+
if (this.verify && this.autoFix) {
|
|
80
|
+
console.log('\n๐ Auto-Fix Mode Enabled');
|
|
81
|
+
console.log(' โข Will automatically fix issues until threshold is met');
|
|
82
|
+
console.log(` โข Maximum iterations: ${this.maxIterations}`);
|
|
83
|
+
console.log(` โข Target threshold: ${this.threshold}`);
|
|
84
|
+
|
|
85
|
+
await this.recursiveFixLoop();
|
|
86
|
+
} else if (this.verify) {
|
|
87
|
+
await this.runVerification();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await this.startInteractiveMode();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Working recursive fix loop that actually applies fixes
|
|
95
|
+
*/
|
|
96
|
+
async recursiveFixLoop() {
|
|
97
|
+
console.log('\n๐ Starting Auto-Fix Loop with Real Fixes...');
|
|
98
|
+
console.log('โ'.repeat(50));
|
|
99
|
+
|
|
100
|
+
let score = 0;
|
|
101
|
+
this.currentIteration = 0;
|
|
102
|
+
|
|
103
|
+
while (score < this.threshold && this.currentIteration < this.maxIterations) {
|
|
104
|
+
this.currentIteration++;
|
|
105
|
+
console.log(`\n๐ Iteration ${this.currentIteration}/${this.maxIterations}`);
|
|
106
|
+
|
|
107
|
+
// Step 1: Run verification
|
|
108
|
+
const verificationResult = await this.runVerification();
|
|
109
|
+
score = verificationResult.score;
|
|
110
|
+
|
|
111
|
+
if (score >= this.threshold) {
|
|
112
|
+
console.log(`\nโจ Threshold met! Score: ${score.toFixed(2)} >= ${this.threshold}`);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Step 2: Apply actual fixes
|
|
117
|
+
console.log('\n๐ง Applying fixes...');
|
|
118
|
+
const fixResults = await this.applyRealFixes(verificationResult);
|
|
119
|
+
|
|
120
|
+
if (fixResults.applied > 0) {
|
|
121
|
+
console.log(` โ
Applied ${fixResults.applied} fixes`);
|
|
122
|
+
this.fixHistory.push({
|
|
123
|
+
iteration: this.currentIteration,
|
|
124
|
+
fixes: fixResults.fixes,
|
|
125
|
+
timestamp: new Date(),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Wait before next iteration
|
|
130
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.showFixSummary();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Apply real fixes to the codebase
|
|
138
|
+
*/
|
|
139
|
+
async applyRealFixes(verificationResult) {
|
|
140
|
+
const fixResults = {
|
|
141
|
+
applied: 0,
|
|
142
|
+
fixes: [],
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Fix linting issues
|
|
146
|
+
if (verificationResult.lintScore < 0.8) {
|
|
147
|
+
console.log(' ๐ง Fixing linting issues...');
|
|
148
|
+
try {
|
|
149
|
+
// First try auto-fix
|
|
150
|
+
const { stdout, stderr } = await execAsync('(npm run lint -- --fix) 2>&1 || true');
|
|
151
|
+
|
|
152
|
+
// Check if fixes were applied
|
|
153
|
+
const afterLint = await execAsync('(npm run lint) 2>&1 || true');
|
|
154
|
+
const stillHasErrors = afterLint.stdout.toLowerCase().includes('error');
|
|
155
|
+
|
|
156
|
+
if (
|
|
157
|
+
!stillHasErrors ||
|
|
158
|
+
afterLint.stdout.match(/error/gi)?.length < stdout.match(/error/gi)?.length
|
|
159
|
+
) {
|
|
160
|
+
console.log(' โ
Applied ESLint auto-fixes');
|
|
161
|
+
fixResults.applied++;
|
|
162
|
+
fixResults.fixes.push('ESLint auto-fix');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// If still has errors, try prettier
|
|
166
|
+
if (stillHasErrors) {
|
|
167
|
+
await execAsync('npx prettier --write "src/**/*.{js,ts,jsx,tsx}" 2>&1 || true');
|
|
168
|
+
console.log(' โ
Applied Prettier formatting');
|
|
169
|
+
fixResults.applied++;
|
|
170
|
+
fixResults.fixes.push('Prettier formatting');
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.log(' โ ๏ธ Some linting issues require manual fixes');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Fix TypeScript issues
|
|
178
|
+
if (verificationResult.typeScore < 0.8) {
|
|
179
|
+
console.log(' ๐ง Analyzing TypeScript errors...');
|
|
180
|
+
try {
|
|
181
|
+
const { stdout: tsErrors } = await execAsync('(npm run typecheck) 2>&1 || true');
|
|
182
|
+
|
|
183
|
+
// Common auto-fixable TypeScript issues
|
|
184
|
+
if (tsErrors.includes('Could not find a declaration file')) {
|
|
185
|
+
console.log(' ๐ฆ Installing missing type definitions...');
|
|
186
|
+
const missingTypes = this.extractMissingTypes(tsErrors);
|
|
187
|
+
for (const pkg of missingTypes) {
|
|
188
|
+
try {
|
|
189
|
+
await execAsync(`npm install --save-dev @types/${pkg} 2>&1 || true`);
|
|
190
|
+
console.log(` โ
Installed @types/${pkg}`);
|
|
191
|
+
fixResults.applied++;
|
|
192
|
+
fixResults.fixes.push(`Installed @types/${pkg}`);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
// Type package might not exist
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Add basic type annotations for 'any' types
|
|
200
|
+
if (tsErrors.includes("implicitly has an 'any' type")) {
|
|
201
|
+
console.log(' ๐ Adding type annotations for implicit any...');
|
|
202
|
+
// This would need more complex AST manipulation in production
|
|
203
|
+
// For now, we'll just report it
|
|
204
|
+
console.log(' โน๏ธ Manual type annotations needed');
|
|
205
|
+
}
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.log(' โ ๏ธ TypeScript fixes require manual intervention');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Fix build issues
|
|
212
|
+
if (verificationResult.buildScore < 0.8) {
|
|
213
|
+
console.log(' ๐ง Fixing build configuration...');
|
|
214
|
+
try {
|
|
215
|
+
// Clear cache and rebuild
|
|
216
|
+
await execAsync('rm -rf dist 2>&1 || true');
|
|
217
|
+
await execAsync('(npm run build) 2>&1 || true');
|
|
218
|
+
console.log(' โ
Cleared cache and rebuilt');
|
|
219
|
+
fixResults.applied++;
|
|
220
|
+
fixResults.fixes.push('Cache clear and rebuild');
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.log(' โ ๏ธ Build issues may require configuration changes');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Fix package issues
|
|
227
|
+
console.log(' ๐ง Checking for dependency issues...');
|
|
228
|
+
try {
|
|
229
|
+
// Audit and fix vulnerabilities
|
|
230
|
+
const { stdout: auditOutput } = await execAsync('npm audit --json 2>&1 || true');
|
|
231
|
+
const audit = JSON.parse(auditOutput);
|
|
232
|
+
|
|
233
|
+
if (audit.metadata?.vulnerabilities?.total > 0) {
|
|
234
|
+
console.log(' ๐ก๏ธ Fixing security vulnerabilities...');
|
|
235
|
+
await execAsync('npm audit fix 2>&1 || true');
|
|
236
|
+
console.log(' โ
Applied security fixes');
|
|
237
|
+
fixResults.applied++;
|
|
238
|
+
fixResults.fixes.push('Security vulnerability fixes');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Update outdated packages (only patch/minor)
|
|
242
|
+
await execAsync('npm update 2>&1 || true');
|
|
243
|
+
console.log(' โ
Updated dependencies');
|
|
244
|
+
fixResults.applied++;
|
|
245
|
+
fixResults.fixes.push('Dependency updates');
|
|
246
|
+
} catch (error) {
|
|
247
|
+
// Audit might fail, that's okay
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return fixResults;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Extract missing type packages from TypeScript errors
|
|
255
|
+
*/
|
|
256
|
+
extractMissingTypes(tsErrors) {
|
|
257
|
+
const packages = new Set();
|
|
258
|
+
const regex = /Could not find a declaration file for module '([^']+)'/g;
|
|
259
|
+
let match;
|
|
260
|
+
|
|
261
|
+
while ((match = regex.exec(tsErrors)) !== null) {
|
|
262
|
+
const pkg = match[1];
|
|
263
|
+
// Clean package name (remove @org/ prefix if present)
|
|
264
|
+
const cleanPkg = pkg.replace(/^@[^/]+\//, '');
|
|
265
|
+
packages.add(cleanPkg);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return Array.from(packages);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Run verification with detailed scoring
|
|
273
|
+
*/
|
|
274
|
+
async runVerification() {
|
|
275
|
+
console.log('\n๐ Running verification check...');
|
|
276
|
+
|
|
277
|
+
const checks = [
|
|
278
|
+
{
|
|
279
|
+
name: 'Type Check',
|
|
280
|
+
command: '(npm run typecheck) 2>&1 || true',
|
|
281
|
+
weight: 0.4,
|
|
282
|
+
scoreKey: 'typeScore',
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: 'Linting',
|
|
286
|
+
command: '(npm run lint) 2>&1 || true',
|
|
287
|
+
weight: 0.3,
|
|
288
|
+
scoreKey: 'lintScore',
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: 'Build',
|
|
292
|
+
command: '(npm run build) 2>&1 || true',
|
|
293
|
+
weight: 0.3,
|
|
294
|
+
scoreKey: 'buildScore',
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
|
|
298
|
+
const results = {};
|
|
299
|
+
let totalScore = 0;
|
|
300
|
+
let totalWeight = 0;
|
|
301
|
+
|
|
302
|
+
for (const check of checks) {
|
|
303
|
+
try {
|
|
304
|
+
const { stdout, stderr } = await execAsync(check.command);
|
|
305
|
+
const output = stdout + stderr;
|
|
306
|
+
|
|
307
|
+
// Calculate score based on actual errors/warnings
|
|
308
|
+
let score = 1.0;
|
|
309
|
+
const errorCount = (output.match(/error/gi) || []).length;
|
|
310
|
+
const warningCount = (output.match(/warning/gi) || []).length;
|
|
311
|
+
|
|
312
|
+
if (errorCount > 0) {
|
|
313
|
+
score = Math.max(0.2, 1.0 - errorCount * 0.1);
|
|
314
|
+
} else if (warningCount > 0) {
|
|
315
|
+
score = Math.max(0.7, 1.0 - warningCount * 0.05);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
results[check.scoreKey] = score;
|
|
319
|
+
totalScore += score * check.weight;
|
|
320
|
+
totalWeight += check.weight;
|
|
321
|
+
|
|
322
|
+
const icon = score >= 0.8 ? 'โ
' : score >= 0.5 ? 'โ ๏ธ' : 'โ';
|
|
323
|
+
console.log(` ${icon} ${check.name}: ${score.toFixed(2)}`);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
console.log(` โ ${check.name}: 0.00 (failed)`);
|
|
326
|
+
results[check.scoreKey] = 0;
|
|
327
|
+
totalWeight += check.weight;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const averageScore = totalWeight > 0 ? totalScore / totalWeight : 0;
|
|
332
|
+
console.log(`\n๐ Verification Score: ${averageScore.toFixed(2)}/${this.threshold}`);
|
|
333
|
+
|
|
334
|
+
if (this.guidanceMode === 'beginner' && averageScore < this.threshold) {
|
|
335
|
+
console.log("\n๐ก Don't worry! Use /autofix to automatically improve the score");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const verificationResult = {
|
|
339
|
+
score: averageScore,
|
|
340
|
+
...results,
|
|
341
|
+
timestamp: new Date(),
|
|
342
|
+
iteration: this.currentIteration,
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
this.verificationScores.push(verificationResult);
|
|
346
|
+
return verificationResult;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
showWelcome() {
|
|
350
|
+
console.log('\n๐ Enhanced Pair Programming Session');
|
|
351
|
+
console.log('โ'.repeat(50));
|
|
352
|
+
console.log(`Session ID: ${this.sessionId}`);
|
|
353
|
+
console.log(
|
|
354
|
+
`Guidance Mode: ${this.guidanceMode.charAt(0).toUpperCase() + this.guidanceMode.slice(1)}`,
|
|
355
|
+
);
|
|
356
|
+
console.log(`Description: ${this.guidance.description}`);
|
|
357
|
+
console.log(`Verification: ${this.verify ? 'โ
Enabled' : 'โ Disabled'}`);
|
|
358
|
+
console.log(`Auto-Fix: ${this.autoFix ? 'โ
Enabled' : 'โ Disabled'}`);
|
|
359
|
+
console.log(`Target Threshold: ${this.threshold}`);
|
|
360
|
+
console.log('โ'.repeat(50));
|
|
361
|
+
|
|
362
|
+
if (this.guidanceMode === 'beginner') {
|
|
363
|
+
console.log('\n๐ Guidance Settings:');
|
|
364
|
+
console.log(
|
|
365
|
+
` โข Mode: ${this.guidanceMode.charAt(0).toUpperCase() + this.guidanceMode.slice(1)}`,
|
|
366
|
+
);
|
|
367
|
+
console.log(` โข Verbosity: ${this.guidance.verbosity}`);
|
|
368
|
+
console.log(` โข Suggestions: ${this.guidance.suggestions}`);
|
|
369
|
+
console.log(` โข Explanations: ${this.guidance.explanations}`);
|
|
370
|
+
|
|
371
|
+
console.log('\n๐ก Beginner Tips:');
|
|
372
|
+
console.log(' โข Use /explain for detailed explanations');
|
|
373
|
+
console.log(' โข Use /pattern to see design patterns');
|
|
374
|
+
console.log(' โข Use /best for best practices');
|
|
375
|
+
console.log(' โข Use /why to understand decisions');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
showFixSummary() {
|
|
380
|
+
if (this.fixHistory.length > 0) {
|
|
381
|
+
console.log('\n๐ Fix Summary:');
|
|
382
|
+
console.log('โ'.repeat(50));
|
|
383
|
+
|
|
384
|
+
let totalFixes = 0;
|
|
385
|
+
for (const entry of this.fixHistory) {
|
|
386
|
+
console.log(`\nIteration ${entry.iteration}:`);
|
|
387
|
+
for (const fix of entry.fixes) {
|
|
388
|
+
console.log(` โ
${fix}`);
|
|
389
|
+
totalFixes++;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
console.log('โ'.repeat(50));
|
|
394
|
+
console.log(`Total fixes applied: ${totalFixes}`);
|
|
395
|
+
console.log(`Iterations completed: ${this.currentIteration}`);
|
|
396
|
+
|
|
397
|
+
if (this.verificationScores.length > 1) {
|
|
398
|
+
const first = this.verificationScores[0].score;
|
|
399
|
+
const last = this.verificationScores[this.verificationScores.length - 1].score;
|
|
400
|
+
const improvement = ((last - first) * 100).toFixed(1);
|
|
401
|
+
if (improvement > 0) {
|
|
402
|
+
console.log(`Score improvement: +${improvement}%`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
async startInteractiveMode() {
|
|
409
|
+
this.rl = readline.createInterface({
|
|
410
|
+
input: process.stdin,
|
|
411
|
+
output: process.stdout,
|
|
412
|
+
prompt: '\n๐ป pair> ',
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
console.log('\n๐ก Interactive mode active. Type /help for commands.\n');
|
|
416
|
+
|
|
417
|
+
this.showCommands();
|
|
418
|
+
this.rl.prompt();
|
|
419
|
+
|
|
420
|
+
this.rl.on('line', async (line) => {
|
|
421
|
+
const input = line.trim();
|
|
422
|
+
|
|
423
|
+
if (input.startsWith('/')) {
|
|
424
|
+
await this.handleCommand(input);
|
|
425
|
+
} else if (input.startsWith('?')) {
|
|
426
|
+
await this.askQuestion(input.slice(1).trim());
|
|
427
|
+
} else if (input) {
|
|
428
|
+
console.log('๐ค Processing your input...');
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
this.rl.prompt();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
this.rl.on('close', () => {
|
|
435
|
+
this.end();
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
showCommands() {
|
|
440
|
+
console.log('\n๐ Session Commands:');
|
|
441
|
+
console.log(' /help - Show all commands');
|
|
442
|
+
console.log(' /verify - Run verification');
|
|
443
|
+
console.log(' /autofix - Start auto-fix loop');
|
|
444
|
+
console.log(' /suggest - Get suggestions');
|
|
445
|
+
console.log(' /explain <topic> - Explain concept');
|
|
446
|
+
console.log(' /best <area> - Show best practices');
|
|
447
|
+
console.log(' /pattern - Pattern suggestions');
|
|
448
|
+
console.log(' /why - Explain decisions');
|
|
449
|
+
console.log(' /status - Session status');
|
|
450
|
+
console.log(' /metrics - Quality metrics');
|
|
451
|
+
console.log(' /guidance - Change guidance mode');
|
|
452
|
+
console.log(' /test - Run tests');
|
|
453
|
+
console.log(' /commit - Commit with verification');
|
|
454
|
+
console.log(' /end - End session');
|
|
455
|
+
|
|
456
|
+
if (this.guidanceMode === 'beginner') {
|
|
457
|
+
console.log('\n๐ก Quick tips:');
|
|
458
|
+
console.log(' โข Type ? followed by question for Q&A');
|
|
459
|
+
console.log(' โข Use Tab for command completion');
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async handleCommand(command) {
|
|
464
|
+
const [cmd, ...args] = command.split(' ');
|
|
465
|
+
|
|
466
|
+
switch (cmd) {
|
|
467
|
+
case '/help':
|
|
468
|
+
this.showCommands();
|
|
469
|
+
break;
|
|
470
|
+
|
|
471
|
+
case '/verify':
|
|
472
|
+
await this.runVerification();
|
|
473
|
+
break;
|
|
474
|
+
|
|
475
|
+
case '/autofix':
|
|
476
|
+
await this.recursiveFixLoop();
|
|
477
|
+
break;
|
|
478
|
+
|
|
479
|
+
case '/suggest':
|
|
480
|
+
await this.showSuggestions();
|
|
481
|
+
break;
|
|
482
|
+
|
|
483
|
+
case '/explain':
|
|
484
|
+
await this.explainConcept(args.join(' '));
|
|
485
|
+
break;
|
|
486
|
+
|
|
487
|
+
case '/best':
|
|
488
|
+
this.showBestPractices(args[0] || 'general');
|
|
489
|
+
break;
|
|
490
|
+
|
|
491
|
+
case '/pattern':
|
|
492
|
+
this.showPatternSuggestions();
|
|
493
|
+
break;
|
|
494
|
+
|
|
495
|
+
case '/why':
|
|
496
|
+
this.explainDecisions();
|
|
497
|
+
break;
|
|
498
|
+
|
|
499
|
+
case '/status':
|
|
500
|
+
await this.showStatus();
|
|
501
|
+
break;
|
|
502
|
+
|
|
503
|
+
case '/metrics':
|
|
504
|
+
this.showMetrics();
|
|
505
|
+
break;
|
|
506
|
+
|
|
507
|
+
case '/guidance':
|
|
508
|
+
await this.changeGuidanceMode(args[0]);
|
|
509
|
+
break;
|
|
510
|
+
|
|
511
|
+
case '/test':
|
|
512
|
+
await this.runTests();
|
|
513
|
+
break;
|
|
514
|
+
|
|
515
|
+
case '/commit':
|
|
516
|
+
await this.commitWithVerification();
|
|
517
|
+
break;
|
|
518
|
+
|
|
519
|
+
case '/end':
|
|
520
|
+
case '/exit':
|
|
521
|
+
await this.end();
|
|
522
|
+
process.exit(0);
|
|
523
|
+
break;
|
|
524
|
+
|
|
525
|
+
default:
|
|
526
|
+
console.log(`โ Unknown command: ${cmd}`);
|
|
527
|
+
console.log('๐ก Type /help for available commands');
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
async showSuggestions() {
|
|
532
|
+
console.log('\n๐ก Analyzing for suggestions...');
|
|
533
|
+
|
|
534
|
+
// Get latest verification scores
|
|
535
|
+
let latestScore = null;
|
|
536
|
+
if (this.verificationScores.length > 0) {
|
|
537
|
+
latestScore = this.verificationScores[this.verificationScores.length - 1];
|
|
538
|
+
} else {
|
|
539
|
+
latestScore = await this.runVerification();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
console.log('\n๐ Immediate Actions:');
|
|
543
|
+
if (latestScore.lintScore < 0.8) {
|
|
544
|
+
console.log(' 1. Fix linting issues: Run /autofix or npm run lint --fix');
|
|
545
|
+
}
|
|
546
|
+
if (latestScore.typeScore < 0.8) {
|
|
547
|
+
console.log(' 2. Fix TypeScript errors: Check npm run typecheck output');
|
|
548
|
+
}
|
|
549
|
+
if (latestScore.buildScore < 0.8) {
|
|
550
|
+
console.log(' 3. Fix build issues: Clear cache and rebuild');
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (latestScore.score >= this.threshold) {
|
|
554
|
+
console.log(' โจ Code quality meets threshold! Consider adding tests or documentation.');
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
async explainConcept(topic) {
|
|
559
|
+
if (!topic) {
|
|
560
|
+
console.log('Usage: /explain <topic>');
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
console.log(`\n๐ Explaining: ${topic}`);
|
|
565
|
+
console.log('โ'.repeat(40));
|
|
566
|
+
|
|
567
|
+
// Provide explanations based on common topics
|
|
568
|
+
const explanations = {
|
|
569
|
+
typescript: 'TypeScript adds static typing to JavaScript, catching errors at compile time.',
|
|
570
|
+
linting: 'Linting analyzes code for potential errors and style issues.',
|
|
571
|
+
testing: 'Tests verify your code works as expected and prevent regressions.',
|
|
572
|
+
async: 'Async/await provides cleaner syntax for handling promises.',
|
|
573
|
+
hooks: 'React hooks allow using state in functional components.',
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
const explanation = explanations[topic.toLowerCase()];
|
|
577
|
+
if (explanation) {
|
|
578
|
+
console.log(explanation);
|
|
579
|
+
} else {
|
|
580
|
+
console.log('Topic not found. Try: typescript, linting, testing, async, hooks');
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
showBestPractices(area) {
|
|
585
|
+
console.log(`\n๐ Best Practices for ${area}:`);
|
|
586
|
+
console.log('โ'.repeat(40));
|
|
587
|
+
|
|
588
|
+
const practices = {
|
|
589
|
+
general: [
|
|
590
|
+
'โข Write self-documenting code',
|
|
591
|
+
'โข Keep functions small and focused',
|
|
592
|
+
'โข Use meaningful variable names',
|
|
593
|
+
'โข Handle errors properly',
|
|
594
|
+
'โข Write tests for critical paths',
|
|
595
|
+
],
|
|
596
|
+
testing: [
|
|
597
|
+
'โข Test behavior, not implementation',
|
|
598
|
+
'โข Use descriptive test names',
|
|
599
|
+
'โข Follow AAA pattern',
|
|
600
|
+
'โข Mock external dependencies',
|
|
601
|
+
'โข Test edge cases',
|
|
602
|
+
],
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
const selected = practices[area] || practices.general;
|
|
606
|
+
selected.forEach((p) => console.log(p));
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
showPatternSuggestions() {
|
|
610
|
+
console.log('\n๐๏ธ Recommended Design Patterns:');
|
|
611
|
+
console.log('โ'.repeat(40));
|
|
612
|
+
console.log('โข Singleton - One instance throughout app');
|
|
613
|
+
console.log('โข Factory - Create objects without specifying class');
|
|
614
|
+
console.log('โข Observer - Subscribe to and notify changes');
|
|
615
|
+
console.log('โข Strategy - Encapsulate algorithms');
|
|
616
|
+
console.log('โข Decorator - Add functionality to objects');
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
explainDecisions() {
|
|
620
|
+
console.log('\n๐ค Decision Rationale:');
|
|
621
|
+
console.log('โ'.repeat(40));
|
|
622
|
+
console.log('Auto-fix decisions are based on:');
|
|
623
|
+
console.log('โข Industry best practices');
|
|
624
|
+
console.log('โข Code maintainability');
|
|
625
|
+
console.log('โข Performance optimization');
|
|
626
|
+
console.log('โข Security considerations');
|
|
627
|
+
console.log('โข Team consistency');
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
async showStatus() {
|
|
631
|
+
const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
|
|
632
|
+
|
|
633
|
+
console.log('\n๐ Session Status');
|
|
634
|
+
console.log('โ'.repeat(40));
|
|
635
|
+
console.log(`Session ID: ${this.sessionId}`);
|
|
636
|
+
console.log(`Duration: ${duration} minutes`);
|
|
637
|
+
console.log(`Guidance Mode: ${this.guidanceMode}`);
|
|
638
|
+
console.log(`Auto-Fix: ${this.autoFix ? 'Enabled' : 'Disabled'}`);
|
|
639
|
+
console.log(`Fix Iterations: ${this.currentIteration}`);
|
|
640
|
+
console.log(
|
|
641
|
+
`Total Fixes Applied: ${this.fixHistory.reduce((sum, h) => sum + h.fixes.length, 0)}`,
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
if (this.verificationScores.length > 0) {
|
|
645
|
+
const latest = this.verificationScores[this.verificationScores.length - 1];
|
|
646
|
+
console.log(`Latest Score: ${latest.score.toFixed(2)}`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
showMetrics() {
|
|
651
|
+
console.log('\n๐ Quality Metrics');
|
|
652
|
+
console.log('โ'.repeat(40));
|
|
653
|
+
|
|
654
|
+
if (this.verificationScores.length > 0) {
|
|
655
|
+
console.log('\nScore Progression:');
|
|
656
|
+
this.verificationScores.forEach((v, i) => {
|
|
657
|
+
const bar = 'โ'.repeat(Math.floor(v.score * 20));
|
|
658
|
+
console.log(` ${i + 1}. ${bar} ${v.score.toFixed(2)}`);
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
if (this.verificationScores.length > 1) {
|
|
662
|
+
const first = this.verificationScores[0].score;
|
|
663
|
+
const last = this.verificationScores[this.verificationScores.length - 1].score;
|
|
664
|
+
const improvement = ((last - first) * 100).toFixed(1);
|
|
665
|
+
if (improvement > 0) {
|
|
666
|
+
console.log(`\n Improvement: +${improvement}%`);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
async changeGuidanceMode(newMode) {
|
|
673
|
+
if (!newMode || !GUIDANCE_MODES[newMode]) {
|
|
674
|
+
console.log('Available modes: beginner, intermediate, expert, mentor, strict');
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
this.guidanceMode = newMode;
|
|
679
|
+
this.guidance = GUIDANCE_MODES[newMode];
|
|
680
|
+
console.log(`โ
Guidance mode changed to: ${newMode}`);
|
|
681
|
+
console.log(`Description: ${this.guidance.description}`);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
async askQuestion(question) {
|
|
685
|
+
console.log('\nโ Question:', question);
|
|
686
|
+
console.log('\n๐ Answer:');
|
|
687
|
+
console.log('โ'.repeat(40));
|
|
688
|
+
|
|
689
|
+
// Provide contextual answers
|
|
690
|
+
if (question.toLowerCase().includes('why')) {
|
|
691
|
+
console.log('This is important for code quality and maintainability.');
|
|
692
|
+
} else if (question.toLowerCase().includes('how')) {
|
|
693
|
+
console.log('You can achieve this by following the suggested approach.');
|
|
694
|
+
} else {
|
|
695
|
+
console.log("That's a great question! Consider exploring the documentation.");
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
async runTests() {
|
|
700
|
+
console.log('\n๐งช Running tests...');
|
|
701
|
+
try {
|
|
702
|
+
const { stdout } = await execAsync('npm test 2>&1 || true');
|
|
703
|
+
const passed = !stdout.toLowerCase().includes('fail');
|
|
704
|
+
console.log(` ${passed ? 'โ
' : 'โ'} Tests ${passed ? 'passed' : 'failed'}`);
|
|
705
|
+
return passed;
|
|
706
|
+
} catch (error) {
|
|
707
|
+
console.log(' โ Test execution failed:', error.message);
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
async commitWithVerification() {
|
|
713
|
+
const result = await this.runVerification();
|
|
714
|
+
|
|
715
|
+
if (result.score >= this.threshold) {
|
|
716
|
+
console.log('โ
Verification passed! Ready to commit.');
|
|
717
|
+
console.log('\n๐ Suggested commit message:');
|
|
718
|
+
console.log(` "feat: improved code quality to ${result.score.toFixed(2)} threshold"`);
|
|
719
|
+
} else {
|
|
720
|
+
console.log('โ Verification failed!');
|
|
721
|
+
console.log('๐ก Run /autofix to automatically fix issues');
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
async end() {
|
|
726
|
+
console.log('\n๐ Ending pair programming session...');
|
|
727
|
+
|
|
728
|
+
if (this.rl) this.rl.close();
|
|
729
|
+
|
|
730
|
+
this.status = 'completed';
|
|
731
|
+
await this.saveSession();
|
|
732
|
+
|
|
733
|
+
const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
|
|
734
|
+
console.log('\nโจ Session Complete!');
|
|
735
|
+
console.log('โ'.repeat(40));
|
|
736
|
+
console.log(`Duration: ${duration} minutes`);
|
|
737
|
+
console.log(
|
|
738
|
+
`Total Fixes Applied: ${this.fixHistory.reduce((sum, h) => sum + h.fixes.length, 0)}`,
|
|
739
|
+
);
|
|
740
|
+
console.log(`Final Iterations: ${this.currentIteration}`);
|
|
741
|
+
|
|
742
|
+
if (this.verificationScores.length > 0) {
|
|
743
|
+
const final = this.verificationScores[this.verificationScores.length - 1];
|
|
744
|
+
console.log(`Final Score: ${final.score.toFixed(2)}`);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
console.log('\n๐ Thanks for pair programming!\n');
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
async saveSession() {
|
|
751
|
+
const sessionPath = '.claude-flow/sessions/pair';
|
|
752
|
+
await fs.mkdir(sessionPath, { recursive: true });
|
|
753
|
+
|
|
754
|
+
const sessionData = {
|
|
755
|
+
id: this.sessionId,
|
|
756
|
+
guidanceMode: this.guidanceMode,
|
|
757
|
+
autoFix: this.autoFix,
|
|
758
|
+
threshold: this.threshold,
|
|
759
|
+
startTime: this.startTime.toISOString(),
|
|
760
|
+
status: this.status,
|
|
761
|
+
verificationScores: this.verificationScores,
|
|
762
|
+
fixHistory: this.fixHistory,
|
|
763
|
+
iterations: this.currentIteration,
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
await fs.writeFile(
|
|
767
|
+
path.join(sessionPath, `${this.sessionId}.json`),
|
|
768
|
+
JSON.stringify(sessionData, null, 2),
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
async function pairCommand(args = [], flags = {}) {
|
|
774
|
+
console.log('\n๐ฅ Enhanced Pair Programming');
|
|
775
|
+
console.log('โ'.repeat(50));
|
|
776
|
+
|
|
777
|
+
if (flags.help || args.includes('--help')) {
|
|
778
|
+
showHelp();
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
if (flags.start) {
|
|
783
|
+
const session = new WorkingPairSession({
|
|
784
|
+
guidance: flags.guidance || 'intermediate',
|
|
785
|
+
verify: flags.verify || false,
|
|
786
|
+
autoFix: flags.autofix || flags.fix || false,
|
|
787
|
+
threshold: parseFloat(flags.threshold) || undefined,
|
|
788
|
+
maxIterations: parseInt(flags.iterations) || 5,
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
return await session.start();
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
showHelp();
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function showHelp() {
|
|
798
|
+
console.log(`
|
|
799
|
+
๐ USAGE:
|
|
800
|
+
claude-flow pair [options]
|
|
801
|
+
|
|
802
|
+
โ๏ธ OPTIONS:
|
|
803
|
+
--start Start a new pair programming session
|
|
804
|
+
--guidance <mode> Set guidance mode (beginner, intermediate, expert, mentor, strict)
|
|
805
|
+
--verify Enable verification
|
|
806
|
+
--autofix, --fix Enable auto-fix with real fixes
|
|
807
|
+
--threshold <n> Target verification threshold
|
|
808
|
+
--iterations <n> Max fix iterations
|
|
809
|
+
--help Show this help message
|
|
810
|
+
|
|
811
|
+
๐ฏ GUIDANCE MODES:
|
|
812
|
+
beginner - Detailed explanations and step-by-step guidance
|
|
813
|
+
intermediate - Balanced guidance with key explanations
|
|
814
|
+
expert - Minimal guidance, maximum efficiency
|
|
815
|
+
mentor - Educational focus with learning opportunities
|
|
816
|
+
strict - Enforces highest code quality standards
|
|
817
|
+
|
|
818
|
+
๐ AUTO-FIX FEATURES:
|
|
819
|
+
โข Real ESLint auto-fixes
|
|
820
|
+
โข Prettier formatting
|
|
821
|
+
โข Missing type definitions installation
|
|
822
|
+
โข Security vulnerability fixes
|
|
823
|
+
โข Dependency updates
|
|
824
|
+
โข Cache clearing and rebuilding
|
|
825
|
+
|
|
826
|
+
๐ก EXAMPLES:
|
|
827
|
+
# Beginner mode with auto-fix
|
|
828
|
+
claude-flow pair --start --guidance beginner --verify --autofix
|
|
829
|
+
|
|
830
|
+
# Expert mode with high threshold
|
|
831
|
+
claude-flow pair --start --guidance expert --verify --autofix --threshold 0.98
|
|
832
|
+
|
|
833
|
+
# Mentor mode (educational, no auto-fix)
|
|
834
|
+
claude-flow pair --start --guidance mentor --verify
|
|
835
|
+
|
|
836
|
+
๐ DURING SESSION:
|
|
837
|
+
/verify - Manual verification
|
|
838
|
+
/autofix - Start auto-fix loop
|
|
839
|
+
/suggest - Get improvement suggestions
|
|
840
|
+
/guidance - Change guidance mode
|
|
841
|
+
/metrics - Show quality metrics
|
|
842
|
+
/status - Current session status
|
|
843
|
+
|
|
844
|
+
๐ For detailed documentation, see:
|
|
845
|
+
.claude/commands/pair/README.md
|
|
846
|
+
`);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export default pairCommand;
|