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.
Files changed (305) hide show
  1. package/.claude-flow-novice/preferences/generation.json +147 -0
  2. package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
  3. package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
  4. package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
  5. package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
  6. package/.claude-flow-novice/preferences/project-local.json +91 -0
  7. package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
  8. package/.claude-flow-novice/preferences/team-shared.json +195 -0
  9. package/.claude-flow-novice/preferences/user-global.json +247 -0
  10. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
  11. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
  12. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
  13. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
  14. package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
  15. package/CLAUDE.md +81 -0
  16. package/README-NPM.md +0 -0
  17. package/package.json +11 -7
  18. package/scripts/build/README.md +167 -0
  19. package/scripts/build/build-config.js +27 -0
  20. package/scripts/build/build-prompt-copier.sh +30 -0
  21. package/scripts/build/performance-monitor.js +869 -0
  22. package/scripts/build/prepare-publish.js +150 -0
  23. package/scripts/build/typescript-fixer.js +621 -0
  24. package/scripts/build/unified-builder.sh +428 -0
  25. package/scripts/build/update-bin-version.js +32 -0
  26. package/scripts/dev/README.md +264 -0
  27. package/scripts/dev/claude-flow-wrapper.sh +35 -0
  28. package/scripts/dev/claude-monitor.py +419 -0
  29. package/scripts/dev/claude-sparc.sh +562 -0
  30. package/scripts/dev/claude-wrapper.sh +17 -0
  31. package/scripts/dev/demo-phase3-compliance.js +172 -0
  32. package/scripts/dev/demo-task-system.ts +224 -0
  33. package/scripts/dev/deployment-validator.js +315 -0
  34. package/scripts/dev/spawn-claude-terminal.sh +32 -0
  35. package/scripts/dev/start-portal.sh +506 -0
  36. package/scripts/dev/start-web-ui.js +15 -0
  37. package/scripts/dev/stop-portal.sh +311 -0
  38. package/scripts/dev/validate-examples.ts +288 -0
  39. package/scripts/dev/validate-phase2.cjs +451 -0
  40. package/scripts/dev/validate-phase2.js +785 -0
  41. package/scripts/dev/validate-phase3.cjs +208 -0
  42. package/scripts/dev/validate-security-remediation.js +1 -0
  43. package/scripts/legacy/README.md +272 -0
  44. package/scripts/legacy/batch-fix-ts.sh +54 -0
  45. package/scripts/legacy/build-migration.sh +105 -0
  46. package/scripts/legacy/build-monitor.js +209 -0
  47. package/scripts/legacy/build-with-filter.sh +84 -0
  48. package/scripts/legacy/build-workaround.sh +71 -0
  49. package/scripts/legacy/fix-ts-advanced.js +358 -0
  50. package/scripts/legacy/fix-ts-final.sh +50 -0
  51. package/scripts/legacy/fix-ts-targeted.sh +49 -0
  52. package/scripts/legacy/fix-typescript-errors.js +305 -0
  53. package/scripts/legacy/force-build.sh +63 -0
  54. package/scripts/legacy/optimize-performance.js +400 -0
  55. package/scripts/legacy/performance-monitor.js +263 -0
  56. package/scripts/legacy/performance-monitoring.js +532 -0
  57. package/scripts/legacy/performance-test-runner.js +645 -0
  58. package/scripts/legacy/quick-fix-ts.js +281 -0
  59. package/scripts/legacy/safe-build.sh +63 -0
  60. package/scripts/migration/README.md +434 -0
  61. package/scripts/migration/install-arm64.js +78 -0
  62. package/scripts/migration/install.js +83 -0
  63. package/scripts/migration/migrate-hooks.js +173 -0
  64. package/scripts/migration/migration-examples.ts +318 -0
  65. package/scripts/optimization/build-optimizer.js +438 -0
  66. package/scripts/optimization/config-validator.js +761 -0
  67. package/scripts/optimization/test-optimization.js +432 -0
  68. package/scripts/optimization/unified-activation.js +839 -0
  69. package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
  70. package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
  71. package/scripts/performance/test-enhanced-backend.sh +504 -0
  72. package/scripts/performance-test-runner.js +698 -0
  73. package/scripts/security/README.md +339 -0
  74. package/scripts/security/install-git-hooks.sh +132 -0
  75. package/scripts/security/ruv-swarm-safe.js +74 -0
  76. package/scripts/test/README.md +236 -0
  77. package/scripts/test/check-links.ts +274 -0
  78. package/scripts/test/check-performance-regression.ts +168 -0
  79. package/scripts/test/coverage-report.ts +692 -0
  80. package/scripts/test/generate-swarm-tests.js +633 -0
  81. package/scripts/test/integration-test-validation.cjs +253 -0
  82. package/scripts/test/load-test-swarm.js +576 -0
  83. package/scripts/test/run-phase3-compliance-tests.js +427 -0
  84. package/scripts/test/test-batch-tasks.ts +29 -0
  85. package/scripts/test/test-byzantine-resolution.js +246 -0
  86. package/scripts/test/test-claude-spawn-options.sh +63 -0
  87. package/scripts/test/test-cli-wizard.js +331 -0
  88. package/scripts/test/test-comprehensive.js +401 -0
  89. package/scripts/test/test-coordination-features.ts +238 -0
  90. package/scripts/test/test-fallback-systems.js +276 -0
  91. package/scripts/test/test-init-command.ts +302 -0
  92. package/scripts/test/test-mcp.ts +251 -0
  93. package/scripts/test/test-runner.ts +568 -0
  94. package/scripts/test/test-swarm-integration.sh +92 -0
  95. package/scripts/test/test-swarm.ts +142 -0
  96. package/scripts/test/validation-summary.ts +408 -0
  97. package/scripts/utils/README.md +261 -0
  98. package/scripts/utils/clean-build-artifacts.sh +94 -0
  99. package/scripts/utils/cleanup-root.sh +69 -0
  100. package/scripts/utils/fix-cliffy-imports.js +307 -0
  101. package/scripts/utils/fix-duplicate-imports.js +114 -0
  102. package/scripts/utils/fix-error-handling.cjs +70 -0
  103. package/scripts/utils/fix-import-paths.js +104 -0
  104. package/scripts/utils/fix-imports.js +116 -0
  105. package/scripts/utils/fix-shebang.js +78 -0
  106. package/scripts/utils/fix-test-modules.js +27 -0
  107. package/scripts/utils/fix-timezone-issue-246.js +200 -0
  108. package/scripts/utils/fix-ts-comprehensive.py +182 -0
  109. package/scripts/utils/fix-ts-targeted-batch.js +250 -0
  110. package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
  111. package/scripts/utils/simple-test-fixer.js +190 -0
  112. package/scripts/utils/validate-metrics-structure.cjs +144 -0
  113. package/scripts/verify-mcp-server.js +86 -0
  114. package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
  115. package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
  116. package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
  117. package/src/cli/simple-commands/__tests__/task.test.js +8 -0
  118. package/src/cli/simple-commands/agent.js +216 -0
  119. package/src/cli/simple-commands/analysis.js +570 -0
  120. package/src/cli/simple-commands/automation-executor.js +1603 -0
  121. package/src/cli/simple-commands/automation.js +627 -0
  122. package/src/cli/simple-commands/batch-manager.js +338 -0
  123. package/src/cli/simple-commands/claude-telemetry.js +311 -0
  124. package/src/cli/simple-commands/claude-track.js +102 -0
  125. package/src/cli/simple-commands/concurrent-display.js +348 -0
  126. package/src/cli/simple-commands/config.js +319 -0
  127. package/src/cli/simple-commands/coordination.js +307 -0
  128. package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
  129. package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
  130. package/src/cli/simple-commands/fix-hook-variables.js +363 -0
  131. package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
  132. package/src/cli/simple-commands/github/github-api.js +624 -0
  133. package/src/cli/simple-commands/github/init.js +543 -0
  134. package/src/cli/simple-commands/github.js +377 -0
  135. package/src/cli/simple-commands/goal.js +145 -0
  136. package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
  137. package/src/cli/simple-commands/hive-mind/communication.js +740 -0
  138. package/src/cli/simple-commands/hive-mind/core.js +1031 -0
  139. package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
  140. package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
  141. package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
  142. package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
  143. package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
  144. package/src/cli/simple-commands/hive-mind/queen.js +809 -0
  145. package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
  146. package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
  147. package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
  148. package/src/cli/simple-commands/hive-mind.js +3112 -0
  149. package/src/cli/simple-commands/hive.js +140 -0
  150. package/src/cli/simple-commands/hook-safety.js +671 -0
  151. package/src/cli/simple-commands/hooks.js +1268 -0
  152. package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
  153. package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
  154. package/src/cli/simple-commands/init/README.md +106 -0
  155. package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
  156. package/src/cli/simple-commands/init/agent-copier.js +347 -0
  157. package/src/cli/simple-commands/init/batch-init.js +663 -0
  158. package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
  159. package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
  160. package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
  161. package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
  162. package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
  163. package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
  164. package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
  165. package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
  166. package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
  167. package/src/cli/simple-commands/init/help.js +110 -0
  168. package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
  169. package/src/cli/simple-commands/init/index.js +1953 -0
  170. package/src/cli/simple-commands/init/performance-monitor.js +344 -0
  171. package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
  172. package/src/cli/simple-commands/init/rollback/index.js +399 -0
  173. package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
  174. package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
  175. package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
  176. package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
  177. package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
  178. package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
  179. package/src/cli/simple-commands/init/sparc-structure.js +68 -0
  180. package/src/cli/simple-commands/init/template-copier.js +640 -0
  181. package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
  182. package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
  183. package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
  184. package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
  185. package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
  186. package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
  187. package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
  188. package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
  189. package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
  190. package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
  191. package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
  192. package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
  193. package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
  194. package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
  195. package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
  196. package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
  197. package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
  198. package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
  199. package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
  200. package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
  201. package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
  202. package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
  203. package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
  204. package/src/cli/simple-commands/init/templates/coordination.md +16 -0
  205. package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
  206. package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
  207. package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
  208. package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
  209. package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
  210. package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
  211. package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
  212. package/src/cli/simple-commands/init/templates/settings.json +109 -0
  213. package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
  214. package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
  215. package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
  216. package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
  217. package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
  218. package/src/cli/simple-commands/init/validation/index.js +388 -0
  219. package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
  220. package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
  221. package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
  222. package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
  223. package/src/cli/simple-commands/init.js +4 -0
  224. package/src/cli/simple-commands/mcp-health.js +163 -0
  225. package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
  226. package/src/cli/simple-commands/mcp.js +420 -0
  227. package/src/cli/simple-commands/memory-consolidation.js +631 -0
  228. package/src/cli/simple-commands/memory.js +345 -0
  229. package/src/cli/simple-commands/migrate-hooks.js +63 -0
  230. package/src/cli/simple-commands/monitor.js +417 -0
  231. package/src/cli/simple-commands/neural.js +148 -0
  232. package/src/cli/simple-commands/pair-autofix-only.js +755 -0
  233. package/src/cli/simple-commands/pair-basic.js +751 -0
  234. package/src/cli/simple-commands/pair-old.js +623 -0
  235. package/src/cli/simple-commands/pair-working.js +849 -0
  236. package/src/cli/simple-commands/pair.js +849 -0
  237. package/src/cli/simple-commands/performance-hooks.js +149 -0
  238. package/src/cli/simple-commands/performance-metrics.js +601 -0
  239. package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
  240. package/src/cli/simple-commands/process-ui.js +274 -0
  241. package/src/cli/simple-commands/realtime-update-system.js +659 -0
  242. package/src/cli/simple-commands/sparc/architecture.js +1750 -0
  243. package/src/cli/simple-commands/sparc/commands.js +575 -0
  244. package/src/cli/simple-commands/sparc/completion.js +1831 -0
  245. package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
  246. package/src/cli/simple-commands/sparc/index.js +321 -0
  247. package/src/cli/simple-commands/sparc/phase-base.js +430 -0
  248. package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
  249. package/src/cli/simple-commands/sparc/refinement.js +1856 -0
  250. package/src/cli/simple-commands/sparc/specification.js +736 -0
  251. package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
  252. package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
  253. package/src/cli/simple-commands/sparc-modes/code.js +148 -0
  254. package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
  255. package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
  256. package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
  257. package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
  258. package/src/cli/simple-commands/sparc-modes/index.js +201 -0
  259. package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
  260. package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
  261. package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
  262. package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
  263. package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
  264. package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
  265. package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
  266. package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
  267. package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
  268. package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
  269. package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
  270. package/src/cli/simple-commands/sparc.js +530 -0
  271. package/src/cli/simple-commands/start-ui.js +147 -0
  272. package/src/cli/simple-commands/start-wrapper.js +285 -0
  273. package/src/cli/simple-commands/start.js +2 -0
  274. package/src/cli/simple-commands/status.js +303 -0
  275. package/src/cli/simple-commands/stream-chain-clean.js +221 -0
  276. package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
  277. package/src/cli/simple-commands/stream-chain-real.js +408 -0
  278. package/src/cli/simple-commands/stream-chain-working.js +323 -0
  279. package/src/cli/simple-commands/stream-chain.js +491 -0
  280. package/src/cli/simple-commands/stream-processor.js +340 -0
  281. package/src/cli/simple-commands/swarm-executor.js +253 -0
  282. package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
  283. package/src/cli/simple-commands/swarm-ui.js +741 -0
  284. package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
  285. package/src/cli/simple-commands/swarm.js +2277 -0
  286. package/src/cli/simple-commands/task.js +228 -0
  287. package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
  288. package/src/cli/simple-commands/timestamp-fix.js +104 -0
  289. package/src/cli/simple-commands/token-tracker.js +372 -0
  290. package/src/cli/simple-commands/tool-execution-framework.js +555 -0
  291. package/src/cli/simple-commands/train-and-stream.js +354 -0
  292. package/src/cli/simple-commands/training-pipeline.js +874 -0
  293. package/src/cli/simple-commands/training.js +288 -0
  294. package/src/cli/simple-commands/verification-hooks.js +336 -0
  295. package/src/cli/simple-commands/verification-integration.js +464 -0
  296. package/src/cli/simple-commands/verification-training-integration.js +646 -0
  297. package/src/cli/simple-commands/verification.js +551 -0
  298. package/src/cli/simple-commands/web-server.js +929 -0
  299. package/src/cli/simple-commands/webui-validator.js +136 -0
  300. package/src/language/README.md +503 -0
  301. package/src/language/claude-md-generator.js +618 -0
  302. package/src/language/cli.js +422 -0
  303. package/src/language/example.js +347 -0
  304. package/src/language/integration-system.js +619 -0
  305. 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;