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,751 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimized Pair Programming Command
|
|
3
|
+
* Interactive pair programming with intelligent verification
|
|
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
|
+
import { watch } from 'fs';
|
|
12
|
+
|
|
13
|
+
const execAsync = promisify(exec);
|
|
14
|
+
|
|
15
|
+
class PairProgrammingSession {
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.sessionId = `pair_${Date.now()}`;
|
|
18
|
+
this.mode = options.mode || 'switch';
|
|
19
|
+
this.agent = options.agent || 'auto';
|
|
20
|
+
this.verify = options.verify || false;
|
|
21
|
+
this.test = options.test || false;
|
|
22
|
+
this.autoVerify = options.autoVerify || false; // New: control automatic verification
|
|
23
|
+
this.threshold = options.threshold || 0.95;
|
|
24
|
+
this.startTime = new Date();
|
|
25
|
+
this.status = 'active';
|
|
26
|
+
this.currentRole = 'driver';
|
|
27
|
+
this.verificationScores = [];
|
|
28
|
+
this.testResults = [];
|
|
29
|
+
this.fileWatchers = new Map();
|
|
30
|
+
this.rl = null;
|
|
31
|
+
this.lastVerificationTime = 0;
|
|
32
|
+
this.verificationCooldown = 60000; // 1 minute cooldown between auto-verifications
|
|
33
|
+
this.isVerifying = false; // Prevent concurrent verifications
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async start() {
|
|
37
|
+
await this.saveSession();
|
|
38
|
+
this.showWelcome();
|
|
39
|
+
|
|
40
|
+
if (this.verify) {
|
|
41
|
+
this.showVerificationSettings();
|
|
42
|
+
|
|
43
|
+
// Only run initial verification once
|
|
44
|
+
if (this.autoVerify) {
|
|
45
|
+
console.log('\nš Running initial verification...');
|
|
46
|
+
await this.runVerification();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (this.test) {
|
|
51
|
+
await this.setupTestWatcher();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
await this.startInteractiveMode();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
showWelcome() {
|
|
58
|
+
console.log('\nš Starting Pair Programming Session');
|
|
59
|
+
console.log('ā'.repeat(50));
|
|
60
|
+
console.log(`Session ID: ${this.sessionId}`);
|
|
61
|
+
console.log(`Mode: ${this.mode}`);
|
|
62
|
+
console.log(`Agent: ${this.agent}`);
|
|
63
|
+
console.log(`Verification: ${this.verify ? 'ā
Enabled' : 'ā Disabled'}`);
|
|
64
|
+
console.log(`Auto-Verify: ${this.autoVerify ? 'ā
Enabled' : 'ā Disabled'}`);
|
|
65
|
+
console.log(`Testing: ${this.test ? 'ā
Enabled' : 'ā Disabled'}`);
|
|
66
|
+
console.log('ā'.repeat(50));
|
|
67
|
+
|
|
68
|
+
// Show mode details
|
|
69
|
+
switch (this.mode) {
|
|
70
|
+
case 'driver':
|
|
71
|
+
console.log('\nš¤ You are the DRIVER - Write code while AI assists');
|
|
72
|
+
console.log('š¤ AI is the NAVIGATOR - Providing guidance and suggestions');
|
|
73
|
+
break;
|
|
74
|
+
case 'navigator':
|
|
75
|
+
console.log('\nš¤ AI is the DRIVER - Writing code based on your guidance');
|
|
76
|
+
console.log('š¤ You are the NAVIGATOR - Providing high-level direction');
|
|
77
|
+
break;
|
|
78
|
+
case 'switch':
|
|
79
|
+
console.log('\nš SWITCH MODE - Roles alternate every 10 minutes');
|
|
80
|
+
console.log(`š¤ Current role: ${this.currentRole.toUpperCase()} (you)`);
|
|
81
|
+
console.log('š¤ AI role: ' + (this.currentRole === 'driver' ? 'NAVIGATOR' : 'DRIVER'));
|
|
82
|
+
this.startRoleTimer();
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.showCommands();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
showCommands() {
|
|
90
|
+
console.log('\nš Session Commands:');
|
|
91
|
+
console.log(' /help - Show available commands');
|
|
92
|
+
console.log(' /switch - Switch driver/navigator roles');
|
|
93
|
+
console.log(' /suggest - Get AI suggestions');
|
|
94
|
+
console.log(' /review - Request code review');
|
|
95
|
+
console.log(' /test - Run tests manually');
|
|
96
|
+
console.log(' /verify - Run verification check');
|
|
97
|
+
console.log(' /status - Show session status');
|
|
98
|
+
console.log(' /metrics - Show quality metrics');
|
|
99
|
+
console.log(' /auto - Toggle auto-verification');
|
|
100
|
+
console.log(' /watch - Toggle file watching');
|
|
101
|
+
console.log(' /commit - Commit with verification');
|
|
102
|
+
console.log(' /end - End session');
|
|
103
|
+
console.log(' /exit - Exit (same as /end)');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
showVerificationSettings() {
|
|
107
|
+
console.log('\nā
Verification Settings:');
|
|
108
|
+
console.log(` ⢠Threshold: ${this.threshold}`);
|
|
109
|
+
console.log(` ⢠Auto-verify: ${this.autoVerify ? 'Enabled' : 'Disabled'}`);
|
|
110
|
+
console.log(` ⢠Manual verify: Always available via /verify`);
|
|
111
|
+
|
|
112
|
+
if (this.autoVerify) {
|
|
113
|
+
console.log(` ⢠Cooldown: ${this.verificationCooldown / 1000}s between checks`);
|
|
114
|
+
console.log(' ⢠Use /auto to toggle automatic verification');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async runVerification() {
|
|
119
|
+
// Prevent concurrent verifications
|
|
120
|
+
if (this.isVerifying) {
|
|
121
|
+
console.log('ā³ Verification already in progress...');
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Check cooldown for automatic verifications
|
|
126
|
+
const now = Date.now();
|
|
127
|
+
if (this.autoVerify && now - this.lastVerificationTime < this.verificationCooldown) {
|
|
128
|
+
const remaining = Math.ceil(
|
|
129
|
+
(this.verificationCooldown - (now - this.lastVerificationTime)) / 1000,
|
|
130
|
+
);
|
|
131
|
+
console.log(`ā±ļø Verification cooldown: ${remaining}s remaining`);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.isVerifying = true;
|
|
136
|
+
this.lastVerificationTime = now;
|
|
137
|
+
|
|
138
|
+
console.log('\nš Running verification check...');
|
|
139
|
+
|
|
140
|
+
const checks = [
|
|
141
|
+
{
|
|
142
|
+
name: 'Type Check',
|
|
143
|
+
command: 'npm run typecheck 2>&1 || true',
|
|
144
|
+
weight: 0.4, // Higher weight for type checking
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'Linting',
|
|
148
|
+
command: 'npm run lint 2>&1 || true',
|
|
149
|
+
weight: 0.3,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Build',
|
|
153
|
+
command: 'npm run build 2>&1 || true',
|
|
154
|
+
weight: 0.3,
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
let totalScore = 0;
|
|
159
|
+
let totalWeight = 0;
|
|
160
|
+
const results = [];
|
|
161
|
+
|
|
162
|
+
for (const check of checks) {
|
|
163
|
+
try {
|
|
164
|
+
const { stdout, stderr } = await execAsync(check.command);
|
|
165
|
+
const output = stdout + stderr;
|
|
166
|
+
|
|
167
|
+
// More intelligent scoring based on actual output
|
|
168
|
+
let score = 1.0;
|
|
169
|
+
|
|
170
|
+
if (output.toLowerCase().includes('error')) {
|
|
171
|
+
const errorCount = (output.match(/error/gi) || []).length;
|
|
172
|
+
score = Math.max(0.2, 1.0 - errorCount * 0.1); // Deduct 0.1 per error, minimum 0.2
|
|
173
|
+
} else if (output.toLowerCase().includes('warning')) {
|
|
174
|
+
const warningCount = (output.match(/warning/gi) || []).length;
|
|
175
|
+
score = Math.max(0.7, 1.0 - warningCount * 0.05); // Deduct 0.05 per warning, minimum 0.7
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
totalScore += score * check.weight;
|
|
179
|
+
totalWeight += check.weight;
|
|
180
|
+
|
|
181
|
+
const icon = score >= 0.8 ? 'ā
' : score >= 0.5 ? 'ā ļø' : 'ā';
|
|
182
|
+
console.log(` ${icon} ${check.name}: ${score.toFixed(2)}`);
|
|
183
|
+
|
|
184
|
+
results.push({ name: check.name, score, output: output.slice(0, 200) });
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.log(` ā ${check.name}: 0.00 (failed to run)`);
|
|
187
|
+
results.push({ name: check.name, score: 0, error: error.message });
|
|
188
|
+
totalWeight += check.weight;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const averageScore = totalWeight > 0 ? totalScore / totalWeight : 0;
|
|
193
|
+
this.verificationScores.push({ score: averageScore, timestamp: now, results });
|
|
194
|
+
|
|
195
|
+
console.log(`\nš Verification Score: ${averageScore.toFixed(2)}/${this.threshold}`);
|
|
196
|
+
|
|
197
|
+
if (averageScore < this.threshold) {
|
|
198
|
+
console.log('ā ļø Verification threshold not met');
|
|
199
|
+
|
|
200
|
+
// Only show detailed help if score is very low
|
|
201
|
+
if (averageScore < 0.5) {
|
|
202
|
+
console.log('\nš” Suggestions:');
|
|
203
|
+
console.log(' ⢠Run /test to check test failures');
|
|
204
|
+
console.log(' ⢠Check TypeScript errors with npm run typecheck');
|
|
205
|
+
console.log(' ⢠Fix linting issues with npm run lint --fix');
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
console.log('ā
Verification passed!');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
this.isVerifying = false;
|
|
212
|
+
return averageScore;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async setupTestWatcher() {
|
|
216
|
+
console.log('\nš§Ŗ Test Configuration:');
|
|
217
|
+
console.log(' ⢠Manual testing via /test command');
|
|
218
|
+
console.log(' ⢠File watching available via /watch');
|
|
219
|
+
|
|
220
|
+
// Don't automatically run tests, wait for user command
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async runTests() {
|
|
224
|
+
console.log('\nš§Ŗ Running tests...');
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
const { stdout, stderr } = await execAsync('npm test 2>&1 || true');
|
|
228
|
+
const output = stdout + stderr;
|
|
229
|
+
const lines = output.split('\n');
|
|
230
|
+
|
|
231
|
+
// Parse test results more intelligently
|
|
232
|
+
const passLine = lines.find((l) => l.includes('passed'));
|
|
233
|
+
const failLine = lines.find((l) => l.includes('failed'));
|
|
234
|
+
const suitesLine = lines.find((l) => l.includes('Test Suites:'));
|
|
235
|
+
|
|
236
|
+
let passed = false;
|
|
237
|
+
let summary = 'No test results found';
|
|
238
|
+
|
|
239
|
+
if (suitesLine) {
|
|
240
|
+
summary = suitesLine.trim();
|
|
241
|
+
passed = !suitesLine.includes('failed');
|
|
242
|
+
} else if (passLine || failLine) {
|
|
243
|
+
summary = (passLine || failLine).trim();
|
|
244
|
+
passed = !!passLine && !failLine;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
console.log(` ${passed ? 'ā
' : 'ā'} ${summary}`);
|
|
248
|
+
|
|
249
|
+
// Extract coverage if available
|
|
250
|
+
const coverageLine = lines.find((l) => l.includes('Coverage') || l.includes('Statements'));
|
|
251
|
+
if (coverageLine) {
|
|
252
|
+
console.log(` š ${coverageLine.trim()}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
this.testResults.push({
|
|
256
|
+
timestamp: new Date(),
|
|
257
|
+
passed,
|
|
258
|
+
summary,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
return passed;
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.log(' ā Test execution failed:', error.message);
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
startRoleTimer() {
|
|
269
|
+
if (this.mode !== 'switch') return;
|
|
270
|
+
|
|
271
|
+
this.roleTimer = setTimeout(
|
|
272
|
+
() => {
|
|
273
|
+
this.switchRoles();
|
|
274
|
+
this.startRoleTimer(); // Restart timer
|
|
275
|
+
},
|
|
276
|
+
10 * 60 * 1000,
|
|
277
|
+
); // 10 minutes
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
switchRoles() {
|
|
281
|
+
const oldRole = this.currentRole;
|
|
282
|
+
this.currentRole = this.currentRole === 'driver' ? 'navigator' : 'driver';
|
|
283
|
+
|
|
284
|
+
console.log('\nš Role Switch!');
|
|
285
|
+
console.log(` Previous role: ${oldRole.toUpperCase()}`);
|
|
286
|
+
console.log(` New role: ${this.currentRole.toUpperCase()}`);
|
|
287
|
+
console.log(' Take a moment to transition...\n');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async startInteractiveMode() {
|
|
291
|
+
this.rl = readline.createInterface({
|
|
292
|
+
input: process.stdin,
|
|
293
|
+
output: process.stdout,
|
|
294
|
+
prompt: '\nš» pair> ',
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
console.log('\nš” Interactive mode active. Type /help for commands.\n');
|
|
298
|
+
|
|
299
|
+
this.rl.prompt();
|
|
300
|
+
|
|
301
|
+
this.rl.on('line', async (line) => {
|
|
302
|
+
const input = line.trim();
|
|
303
|
+
|
|
304
|
+
if (input.startsWith('/')) {
|
|
305
|
+
await this.handleCommand(input);
|
|
306
|
+
} else if (input) {
|
|
307
|
+
// Handle regular input as code discussion
|
|
308
|
+
console.log('š¤ AI: Processing your input...');
|
|
309
|
+
// In a real implementation, this would send to AI
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
this.rl.prompt();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
this.rl.on('close', () => {
|
|
316
|
+
this.end();
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async handleCommand(command) {
|
|
321
|
+
const [cmd, ...args] = command.split(' ');
|
|
322
|
+
|
|
323
|
+
switch (cmd) {
|
|
324
|
+
case '/help':
|
|
325
|
+
this.showCommands();
|
|
326
|
+
break;
|
|
327
|
+
|
|
328
|
+
case '/switch':
|
|
329
|
+
this.switchRoles();
|
|
330
|
+
break;
|
|
331
|
+
|
|
332
|
+
case '/suggest':
|
|
333
|
+
console.log('š¤ AI Suggestion: Consider using async/await for better readability');
|
|
334
|
+
console.log(' Also check error handling in promise chains');
|
|
335
|
+
break;
|
|
336
|
+
|
|
337
|
+
case '/review':
|
|
338
|
+
console.log('š Starting code review...');
|
|
339
|
+
await this.runVerification();
|
|
340
|
+
break;
|
|
341
|
+
|
|
342
|
+
case '/test':
|
|
343
|
+
await this.runTests();
|
|
344
|
+
break;
|
|
345
|
+
|
|
346
|
+
case '/verify':
|
|
347
|
+
await this.runVerification();
|
|
348
|
+
break;
|
|
349
|
+
|
|
350
|
+
case '/status':
|
|
351
|
+
await this.showStatus();
|
|
352
|
+
break;
|
|
353
|
+
|
|
354
|
+
case '/metrics':
|
|
355
|
+
this.showMetrics();
|
|
356
|
+
break;
|
|
357
|
+
|
|
358
|
+
case '/auto':
|
|
359
|
+
this.autoVerify = !this.autoVerify;
|
|
360
|
+
console.log(`\nš Auto-verification ${this.autoVerify ? 'enabled' : 'disabled'}`);
|
|
361
|
+
if (this.autoVerify) {
|
|
362
|
+
console.log(` Cooldown: ${this.verificationCooldown / 1000}s between checks`);
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
|
|
366
|
+
case '/watch':
|
|
367
|
+
console.log('š File watching not yet implemented');
|
|
368
|
+
console.log(' Use /verify or /test for manual checks');
|
|
369
|
+
break;
|
|
370
|
+
|
|
371
|
+
case '/commit':
|
|
372
|
+
await this.commitWithVerification();
|
|
373
|
+
break;
|
|
374
|
+
|
|
375
|
+
case '/end':
|
|
376
|
+
case '/exit':
|
|
377
|
+
await this.end();
|
|
378
|
+
process.exit(0);
|
|
379
|
+
break;
|
|
380
|
+
|
|
381
|
+
default:
|
|
382
|
+
console.log(`ā Unknown command: ${cmd}`);
|
|
383
|
+
console.log('š” Type /help for available commands');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async showStatus() {
|
|
388
|
+
const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
|
|
389
|
+
|
|
390
|
+
console.log('\nš Session Status');
|
|
391
|
+
console.log('ā'.repeat(40));
|
|
392
|
+
console.log(`Session ID: ${this.sessionId}`);
|
|
393
|
+
console.log(`Duration: ${duration} minutes`);
|
|
394
|
+
console.log(`Current Role: ${this.currentRole.toUpperCase()}`);
|
|
395
|
+
console.log(`Mode: ${this.mode}`);
|
|
396
|
+
console.log(`Status: ${this.status}`);
|
|
397
|
+
console.log(`Auto-Verify: ${this.autoVerify ? 'Enabled' : 'Disabled'}`);
|
|
398
|
+
|
|
399
|
+
if (this.verify && this.verificationScores.length > 0) {
|
|
400
|
+
const recent = this.verificationScores[this.verificationScores.length - 1];
|
|
401
|
+
console.log(
|
|
402
|
+
`Last Verification: ${recent.score.toFixed(2)} (${new Date(recent.timestamp).toLocaleTimeString()})`,
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (this.test && this.testResults.length > 0) {
|
|
407
|
+
const passed = this.testResults.filter((r) => r.passed).length;
|
|
408
|
+
console.log(`Tests Passed: ${passed}/${this.testResults.length}`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
showMetrics() {
|
|
413
|
+
console.log('\nš Quality Metrics');
|
|
414
|
+
console.log('ā'.repeat(40));
|
|
415
|
+
|
|
416
|
+
if (this.verificationScores.length > 0) {
|
|
417
|
+
console.log('\nVerification History:');
|
|
418
|
+
this.verificationScores.slice(-5).forEach((item, i) => {
|
|
419
|
+
const bar = 'ā'.repeat(Math.floor(item.score * 20));
|
|
420
|
+
const time = new Date(item.timestamp).toLocaleTimeString();
|
|
421
|
+
console.log(` ${i + 1}. ${bar} ${item.score.toFixed(2)} - ${time}`);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Show average
|
|
425
|
+
const avg =
|
|
426
|
+
this.verificationScores.reduce((sum, item) => sum + item.score, 0) /
|
|
427
|
+
this.verificationScores.length;
|
|
428
|
+
console.log(`\n Average: ${avg.toFixed(2)}`);
|
|
429
|
+
} else {
|
|
430
|
+
console.log('\n No verification history yet');
|
|
431
|
+
console.log(' Run /verify to check code quality');
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (this.testResults.length > 0) {
|
|
435
|
+
console.log('\nTest Results:');
|
|
436
|
+
this.testResults.slice(-5).forEach((result, i) => {
|
|
437
|
+
console.log(
|
|
438
|
+
` ${i + 1}. ${result.passed ? 'ā
' : 'ā'} ${new Date(result.timestamp).toLocaleTimeString()}`,
|
|
439
|
+
);
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
// Show success rate
|
|
443
|
+
const passed = this.testResults.filter((r) => r.passed).length;
|
|
444
|
+
const rate = ((passed / this.testResults.length) * 100).toFixed(0);
|
|
445
|
+
console.log(`\n Success Rate: ${rate}%`);
|
|
446
|
+
} else {
|
|
447
|
+
console.log('\n No test history yet');
|
|
448
|
+
console.log(' Run /test to execute test suite');
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async commitWithVerification() {
|
|
453
|
+
console.log('\nš Pre-commit verification...');
|
|
454
|
+
|
|
455
|
+
const score = await this.runVerification();
|
|
456
|
+
|
|
457
|
+
if (score === null) {
|
|
458
|
+
console.log('ā³ Please wait for cooldown or use /verify manually');
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (score >= this.threshold) {
|
|
463
|
+
console.log('ā
Verification passed! Ready to commit.');
|
|
464
|
+
console.log('\nš” Next steps:');
|
|
465
|
+
console.log(' 1. Review changes: git diff');
|
|
466
|
+
console.log(' 2. Stage files: git add .');
|
|
467
|
+
console.log(' 3. Commit: git commit -m "your message"');
|
|
468
|
+
} else {
|
|
469
|
+
console.log('ā Verification failed!');
|
|
470
|
+
console.log('\nš” Fix issues before committing:');
|
|
471
|
+
console.log(' ⢠Run npm run typecheck to see TypeScript errors');
|
|
472
|
+
console.log(' ⢠Run npm run lint to check code style');
|
|
473
|
+
console.log(' ⢠Run npm run build to verify compilation');
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
async end() {
|
|
478
|
+
console.log('\nš Ending pair programming session...');
|
|
479
|
+
|
|
480
|
+
// Clear timers
|
|
481
|
+
if (this.roleTimer) clearTimeout(this.roleTimer);
|
|
482
|
+
if (this.rl) this.rl.close();
|
|
483
|
+
|
|
484
|
+
// Update session
|
|
485
|
+
this.status = 'completed';
|
|
486
|
+
await this.saveSession();
|
|
487
|
+
|
|
488
|
+
// Show summary
|
|
489
|
+
const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
|
|
490
|
+
console.log('\n⨠Session Complete!');
|
|
491
|
+
console.log('ā'.repeat(40));
|
|
492
|
+
console.log(`Duration: ${duration} minutes`);
|
|
493
|
+
|
|
494
|
+
if (this.verificationScores.length > 0) {
|
|
495
|
+
const avg =
|
|
496
|
+
this.verificationScores.reduce((sum, item) => sum + item.score, 0) /
|
|
497
|
+
this.verificationScores.length;
|
|
498
|
+
console.log(`Average Verification: ${avg.toFixed(2)}`);
|
|
499
|
+
console.log(`Total Checks: ${this.verificationScores.length}`);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (this.testResults.length > 0) {
|
|
503
|
+
const passed = this.testResults.filter((r) => r.passed).length;
|
|
504
|
+
console.log(`Test Success Rate: ${((passed / this.testResults.length) * 100).toFixed(0)}%`);
|
|
505
|
+
console.log(`Total Test Runs: ${this.testResults.length}`);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
console.log('\nš Thanks for pair programming!\n');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async saveSession() {
|
|
512
|
+
const sessionPath = '.claude-flow/sessions/pair';
|
|
513
|
+
await fs.mkdir(sessionPath, { recursive: true });
|
|
514
|
+
|
|
515
|
+
const sessionData = {
|
|
516
|
+
id: this.sessionId,
|
|
517
|
+
mode: this.mode,
|
|
518
|
+
agent: this.agent,
|
|
519
|
+
verify: this.verify,
|
|
520
|
+
autoVerify: this.autoVerify,
|
|
521
|
+
test: this.test,
|
|
522
|
+
threshold: this.threshold,
|
|
523
|
+
startTime: this.startTime.toISOString(),
|
|
524
|
+
status: this.status,
|
|
525
|
+
currentRole: this.currentRole,
|
|
526
|
+
verificationScores: this.verificationScores,
|
|
527
|
+
testResults: this.testResults,
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
await fs.writeFile(
|
|
531
|
+
path.join(sessionPath, `${this.sessionId}.json`),
|
|
532
|
+
JSON.stringify(sessionData, null, 2),
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
async function pairCommand(args = [], flags = {}) {
|
|
538
|
+
console.log('\nš„ Pair Programming Session');
|
|
539
|
+
console.log('ā'.repeat(50));
|
|
540
|
+
|
|
541
|
+
// Handle help flag
|
|
542
|
+
if (flags.help || args.includes('--help')) {
|
|
543
|
+
showHelp();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Handle background execution
|
|
548
|
+
if (flags.background || flags.bg) {
|
|
549
|
+
return startBackgroundSession(args, flags);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// Handle start flag
|
|
553
|
+
if (flags.start) {
|
|
554
|
+
const session = new PairProgrammingSession({
|
|
555
|
+
mode: flags.mode || 'switch',
|
|
556
|
+
agent: flags.agent || 'auto',
|
|
557
|
+
verify: flags.verify || false,
|
|
558
|
+
test: flags.test || false,
|
|
559
|
+
autoVerify: flags.auto || false, // New flag for automatic verification
|
|
560
|
+
threshold: parseFloat(flags.threshold) || 0.95,
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
return await session.start();
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// Handle status flag
|
|
567
|
+
if (flags.status) {
|
|
568
|
+
return showSessionStatus();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Handle end flag
|
|
572
|
+
if (flags.end) {
|
|
573
|
+
return endSession(flags.sessionId || 'current');
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Default: show help
|
|
577
|
+
showHelp();
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function showHelp() {
|
|
581
|
+
console.log(`
|
|
582
|
+
š USAGE:
|
|
583
|
+
claude-flow pair [options]
|
|
584
|
+
|
|
585
|
+
āļø OPTIONS:
|
|
586
|
+
--start Start a new pair programming session
|
|
587
|
+
--end End current session
|
|
588
|
+
--status Show session status
|
|
589
|
+
--mode <type> Programming mode: driver, navigator, switch (default: switch)
|
|
590
|
+
--agent <name> AI pair partner (default: auto-select)
|
|
591
|
+
--verify Enable verification (manual via /verify)
|
|
592
|
+
--auto Enable automatic verification (with cooldown)
|
|
593
|
+
--test Enable testing (manual via /test)
|
|
594
|
+
--threshold <n> Verification threshold (default: 0.95)
|
|
595
|
+
--background, --bg Run in background
|
|
596
|
+
--help Show this help message
|
|
597
|
+
|
|
598
|
+
š MODES:
|
|
599
|
+
driver You write code, AI assists
|
|
600
|
+
navigator AI writes code, you guide
|
|
601
|
+
switch Automatically alternate roles every 10 minutes
|
|
602
|
+
|
|
603
|
+
šÆ SESSION COMMANDS:
|
|
604
|
+
/help Show available commands
|
|
605
|
+
/switch Switch driver/navigator roles
|
|
606
|
+
/suggest Get AI suggestions
|
|
607
|
+
/review Request code review
|
|
608
|
+
/test Run tests manually
|
|
609
|
+
/verify Run verification check
|
|
610
|
+
/status Show session status
|
|
611
|
+
/metrics Show quality metrics
|
|
612
|
+
/auto Toggle auto-verification
|
|
613
|
+
/watch Toggle file watching
|
|
614
|
+
/commit Commit with verification
|
|
615
|
+
/end End session
|
|
616
|
+
|
|
617
|
+
š” EXAMPLES:
|
|
618
|
+
# Basic session with manual verification
|
|
619
|
+
claude-flow pair --start --verify
|
|
620
|
+
|
|
621
|
+
# Session with automatic verification (60s cooldown)
|
|
622
|
+
claude-flow pair --start --verify --auto
|
|
623
|
+
|
|
624
|
+
# Driver mode with testing
|
|
625
|
+
claude-flow pair --start --mode driver --test
|
|
626
|
+
|
|
627
|
+
# Check session status
|
|
628
|
+
claude-flow pair --status
|
|
629
|
+
|
|
630
|
+
šÆ OPTIMIZATION TIPS:
|
|
631
|
+
⢠Use /verify manually when needed
|
|
632
|
+
⢠Enable --auto only for continuous monitoring
|
|
633
|
+
⢠Use /metrics to track quality trends
|
|
634
|
+
⢠Run /test before commits
|
|
635
|
+
|
|
636
|
+
š For detailed documentation, see:
|
|
637
|
+
.claude/commands/pair/README.md
|
|
638
|
+
`);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
async function startBackgroundSession(args, flags) {
|
|
642
|
+
console.log('\nš Starting pair session in background...');
|
|
643
|
+
|
|
644
|
+
const child = spawn(
|
|
645
|
+
process.argv[0],
|
|
646
|
+
[
|
|
647
|
+
process.argv[1],
|
|
648
|
+
'pair',
|
|
649
|
+
'--start',
|
|
650
|
+
...args.filter((arg) => arg !== '--background' && arg !== '--bg'),
|
|
651
|
+
],
|
|
652
|
+
{
|
|
653
|
+
detached: true,
|
|
654
|
+
stdio: 'ignore',
|
|
655
|
+
},
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
child.unref();
|
|
659
|
+
|
|
660
|
+
const pid = child.pid;
|
|
661
|
+
console.log(`ā
Background session started (PID: ${pid})`);
|
|
662
|
+
console.log('\nš Monitor with: claude-flow pair --status');
|
|
663
|
+
console.log('š Stop with: claude-flow pair --end\n');
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
async function showSessionStatus() {
|
|
667
|
+
try {
|
|
668
|
+
const sessionPath = '.claude-flow/sessions/pair';
|
|
669
|
+
const files = await fs.readdir(sessionPath);
|
|
670
|
+
const sessions = [];
|
|
671
|
+
|
|
672
|
+
for (const file of files) {
|
|
673
|
+
if (file.endsWith('.json')) {
|
|
674
|
+
const data = await fs.readFile(path.join(sessionPath, file), 'utf8');
|
|
675
|
+
sessions.push(JSON.parse(data));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (sessions.length === 0) {
|
|
680
|
+
console.log('\nā No active pair programming sessions\n');
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
console.log('\nš Pair Programming Sessions:');
|
|
685
|
+
console.log('ā'.repeat(50));
|
|
686
|
+
|
|
687
|
+
for (const session of sessions.filter((s) => s.status === 'active')) {
|
|
688
|
+
const duration = Math.floor((Date.now() - new Date(session.startTime).getTime()) / 1000 / 60);
|
|
689
|
+
console.log(`\nš¹ Session: ${session.id}`);
|
|
690
|
+
console.log(` Mode: ${session.mode}`);
|
|
691
|
+
console.log(` Duration: ${duration} minutes`);
|
|
692
|
+
console.log(` Status: ${session.status}`);
|
|
693
|
+
console.log(` Verification: ${session.verify ? 'ā
' : 'ā'}`);
|
|
694
|
+
console.log(` Auto-Verify: ${session.autoVerify ? 'ā
' : 'ā'}`);
|
|
695
|
+
console.log(` Testing: ${session.test ? 'ā
' : 'ā'}`);
|
|
696
|
+
|
|
697
|
+
if (session.verificationScores && session.verificationScores.length > 0) {
|
|
698
|
+
const scores = session.verificationScores.map((s) => s.score || s);
|
|
699
|
+
const avg = scores.reduce((a, b) => a + b, 0) / scores.length;
|
|
700
|
+
console.log(` Avg Verification: ${avg.toFixed(2)}`);
|
|
701
|
+
console.log(` Total Checks: ${scores.length}`);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
console.log('ā'.repeat(50));
|
|
706
|
+
} catch (error) {
|
|
707
|
+
console.log('\nā No active pair programming sessions\n');
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
async function endSession(sessionId) {
|
|
712
|
+
console.log(`\nš Ending pair programming session: ${sessionId}`);
|
|
713
|
+
|
|
714
|
+
try {
|
|
715
|
+
const sessionPath = '.claude-flow/sessions/pair';
|
|
716
|
+
|
|
717
|
+
if (sessionId === 'current') {
|
|
718
|
+
// End most recent active session
|
|
719
|
+
const files = await fs.readdir(sessionPath);
|
|
720
|
+
for (const file of files.filter((f) => f.endsWith('.json'))) {
|
|
721
|
+
const data = await fs.readFile(path.join(sessionPath, file), 'utf8');
|
|
722
|
+
const session = JSON.parse(data);
|
|
723
|
+
if (session.status === 'active') {
|
|
724
|
+
sessionId = session.id;
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
const sessionFile = path.join(sessionPath, `${sessionId}.json`);
|
|
731
|
+
const data = await fs.readFile(sessionFile, 'utf8');
|
|
732
|
+
const session = JSON.parse(data);
|
|
733
|
+
|
|
734
|
+
session.status = 'completed';
|
|
735
|
+
session.endTime = new Date().toISOString();
|
|
736
|
+
|
|
737
|
+
await fs.writeFile(sessionFile, JSON.stringify(session, null, 2));
|
|
738
|
+
|
|
739
|
+
console.log('ā
Session ended successfully');
|
|
740
|
+
console.log(`\nš Session Summary:`);
|
|
741
|
+
console.log(
|
|
742
|
+
` Duration: ${Math.floor((new Date(session.endTime) - new Date(session.startTime)) / 1000 / 60)} minutes`,
|
|
743
|
+
);
|
|
744
|
+
console.log(` Mode: ${session.mode}`);
|
|
745
|
+
console.log(` Agent: ${session.agent}\n`);
|
|
746
|
+
} catch (error) {
|
|
747
|
+
console.log('ā Failed to end session:', error.message);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
export default pairCommand;
|