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