Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

🏁 Session end checkpoint: session-20250812-223458

rUvea48b36419a2
diff --git a/.claude-flow/metrics/performance.json b/.claude-flow/metrics/performance.json
index 42974479e8..8323eb30df 100644
--- a/.claude-flow/metrics/performance.json
+++ b/.claude-flow/metrics/performance.json
@@ -1,5 +1,5 @@
{
- "startTime": 1755037034430,
+ "startTime": 1755038087439,
"totalTasks": 1,
"successfulTasks": 1,
"failedTasks": 0,
diff --git a/.claude-flow/metrics/system-metrics.json b/.claude-flow/metrics/system-metrics.json
index 4775aa9b52..be48ae46e3 100644
--- a/.claude-flow/metrics/system-metrics.json
+++ b/.claude-flow/metrics/system-metrics.json
@@ -730,5 +730,89 @@
"cpuLoad": 0.079375,
"platform": "linux",
"uptime": 3326
+ },
+ {
+ "timestamp": 1755037892121,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5631574016,
+ "memoryFree": 61795971072,
+ "memoryUsagePercent": 8.352037744589701,
+ "memoryEfficiency": 91.6479622554103,
+ "cpuCount": 16,
+ "cpuLoad": 0.06875,
+ "platform": "linux",
+ "uptime": 3356.01
+ },
+ {
+ "timestamp": 1755037922150,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5659176960,
+ "memoryFree": 61768368128,
+ "memoryUsagePercent": 8.39297493719248,
+ "memoryEfficiency": 91.60702506280752,
+ "cpuCount": 16,
+ "cpuLoad": 0.060625,
+ "platform": "linux",
+ "uptime": 3386.04
+ },
+ {
+ "timestamp": 1755037952180,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5664354304,
+ "memoryFree": 61763190784,
+ "memoryUsagePercent": 8.400653318473074,
+ "memoryEfficiency": 91.59934668152692,
+ "cpuCount": 16,
+ "cpuLoad": 0.045,
+ "platform": "linux",
+ "uptime": 3416.07
+ },
+ {
+ "timestamp": 1755037982210,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5611683840,
+ "memoryFree": 61815861248,
+ "memoryUsagePercent": 8.322539153214262,
+ "memoryEfficiency": 91.67746084678573,
+ "cpuCount": 16,
+ "cpuLoad": 0.044375,
+ "platform": "linux",
+ "uptime": 3446.1
+ },
+ {
+ "timestamp": 1755038012215,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5708636160,
+ "memoryFree": 61718908928,
+ "memoryUsagePercent": 8.46632656216333,
+ "memoryEfficiency": 91.53367343783667,
+ "cpuCount": 16,
+ "cpuLoad": 0.034375,
+ "platform": "linux",
+ "uptime": 3476.1
+ },
+ {
+ "timestamp": 1755038042232,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5774188544,
+ "memoryFree": 61653356544,
+ "memoryUsagePercent": 8.563545560592603,
+ "memoryEfficiency": 91.4364544394074,
+ "cpuCount": 16,
+ "cpuLoad": 0.059375,
+ "platform": "linux",
+ "uptime": 3506.12
+ },
+ {
+ "timestamp": 1755038072253,
+ "memoryTotal": 67427545088,
+ "memoryUsed": 5661278208,
+ "memoryFree": 61766266880,
+ "memoryUsagePercent": 8.396091242253355,
+ "memoryEfficiency": 91.60390875774664,
+ "cpuCount": 16,
+ "cpuLoad": 0.056875,
+ "platform": "linux",
+ "uptime": 3536.14
}
]
\ No newline at end of file
diff --git a/.claude-flow/metrics/task-metrics.json b/.claude-flow/metrics/task-metrics.json
index 09d6bf3c1c..0c013b13d3 100644
--- a/.claude-flow/metrics/task-metrics.json
+++ b/.claude-flow/metrics/task-metrics.json
@@ -1,10 +1,10 @@
[
{
- "id": "cmd-hooks-1755037034542",
+ "id": "cmd-hooks-1755038087538",
"type": "hooks",
"success": true,
- "duration": 97.90461199999999,
- "timestamp": 1755037034640,
+ "duration": 7.265036999999978,
+ "timestamp": 1755038087545,
"metadata": {}
}
]
\ No newline at end of file
diff --git a/.claude/checkpoints/1755038084.json b/.claude/checkpoints/1755038084.json
new file mode 100644
index 0000000000..ecc8775ee5
--- /dev/null
+++ b/.claude/checkpoints/1755038084.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250812-223444", "file": "/workspaces/claude-code-flow/docs/pair-optimization.md", "timestamp": "2025-08-12T22:34:44Z", "type": "pre-edit", "original_branch": "alpha-89"}
diff --git a/.claude/checkpoints/1755038086.json b/.claude/checkpoints/1755038086.json
new file mode 100644
index 0000000000..dacba97e83
--- /dev/null
+++ b/.claude/checkpoints/1755038086.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250812-223446", "file": "/workspaces/claude-code-flow/docs/pair-optimization.md", "timestamp": "2025-08-12T22:34:46Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 84 ++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude-flow/sessions/pair/pair_1755038032183.json | 14 + .claude-flow/sessions/pair/pair_1755038043176.json | 14 + .claude/checkpoints/1755038007.json | 1 + .claude/checkpoints/1755038009.json | 1 + claude-flow-wiki | 0 docs/pair-optimization.md | 156 +++++++++++ .../{pair-optimized.js => pair-old.js} | 299 ++++++--------------- src/cli/simple-commands/pair.js | 299 +++++++++++++++------ 11 files changed, 573 insertions(+), 303 deletions(-) "}
diff --git a/.claude/checkpoints/summary-session-20250812-223458.md b/.claude/checkpoints/summary-session-20250812-223458.md
new file mode 100644
index 0000000000..f77bd86c36
--- /dev/null
+++ b/.claude/checkpoints/summary-session-20250812-223458.md
@@ -0,0 +1,729 @@
+# Session Summary - 2025-08-12 22:34:58
+
+## Checkpoints Created
+1754966231.json
+1754966233.json
+1754966298.json
+1754966300.json
+1754966304.json
+1754966306.json
+1754966323.json
+1754966325.json
+1754966328.json
+1754966330.json
+1754966365.json
+1754966367.json
+1754966393.json
+1754966395.json
+1754966396.json
+1754966413.json
+1754966415.json
+1754966416.json
+1754966418.json
+1754966424.json
+1754966425.json
+1754966447.json
+1754966449.json
+1754966457.json
+1754966458.json
+1754966459.json
+1754966461.json
+1754966462.json
+1754966464.json
+1754966465.json
+1754966466.json
+1754966468.json
+1754966469.json
+1754966470.json
+1754966471.json
+1754966472.json
+1754966500.json
+1754966502.json
+1754966509.json
+1754966510.json
+1754966511.json
+1754966512.json
+1754966513.json
+1754966514.json
+1754966516.json
+1754966517.json
+1754966533.json
+1754966535.json
+1754966537.json
+1754966538.json
+1754966540.json
+1754966542.json
+1754966544.json
+1754966545.json
+1754966560.json
+1754966562.json
+1754966574.json
+1754966576.json
+1754966578.json
+1754966580.json
+1754966581.json
+1754966583.json
+1754966584.json
+1754966586.json
+1754966588.json
+1754966589.json
+1754966591.json
+1754966593.json
+1754966604.json
+1754966606.json
+1754966614.json
+1754966620.json
+1754966623.json
+1754966634.json
+1754966636.json
+1754966644.json
+1754966645.json
+1754966649.json
+1754966655.json
+1754966659.json
+1754966661.json
+1754966663.json
+1754966666.json
+1754966668.json
+1754966673.json
+1754966678.json
+1754966680.json
+1754966689.json
+1754966693.json
+1754966700.json
+1754966704.json
+1754966708.json
+1754966718.json
+1754966723.json
+1754966728.json
+1754966732.json
+1754966761.json
+1754966765.json
+1754966770.json
+1754966773.json
+1754966781.json
+1754966789.json
+1754966799.json
+1754966805.json
+1754966828.json
+1754966831.json
+1754966877.json
+1754966881.json
+1754966954.json
+1754966958.json
+1754966967.json
+1754966970.json
+1754966974.json
+1754966979.json
+1754966981.json
+1754966984.json
+1754967027.json
+1754967031.json
+1754967035.json
+1754967039.json
+1755008208.json
+1755008210.json
+1755008364.json
+1755008367.json
+1755008382.json
+1755008384.json
+1755008392.json
+1755008394.json
+1755008405.json
+1755008406.json
+1755008723.json
+1755008796.json
+1755008819.json
+1755008840.json
+1755008856.json
+1755008931.json
+1755008933.json
+1755008971.json
+1755008973.json
+1755009483.json
+1755009485.json
+1755009575.json
+1755009576.json
+1755009587.json
+1755009589.json
+1755009611.json
+1755009613.json
+1755009652.json
+1755009653.json
+1755009662.json
+1755009664.json
+1755009673.json
+1755009675.json
+1755009689.json
+1755009691.json
+1755009705.json
+1755009706.json
+1755009717.json
+1755009719.json
+1755009777.json
+1755009779.json
+1755010192.json
+1755010227.json
+1755010245.json
+1755010254.json
+1755010355.json
+1755010425.json
+1755010448.json
+1755010809.json
+1755010811.json
+1755010995.json
+1755010997.json
+1755011011.json
+1755011012.json
+1755011438.json
+1755011439.json
+1755011457.json
+1755011458.json
+1755011472.json
+1755011473.json
+1755011510.json
+1755011512.json
+1755011529.json
+1755011530.json
+1755012655.json
+1755012657.json
+1755012781.json
+1755012783.json
+1755012824.json
+1755012826.json
+1755012882.json
+1755012884.json
+1755012892.json
+1755012894.json
+1755012901.json
+1755012903.json
+1755012941.json
+1755012943.json
+1755012994.json
+1755012996.json
+1755013112.json
+1755013114.json
+1755013187.json
+1755013188.json
+1755013201.json
+1755013203.json
+1755013298.json
+1755013300.json
+1755013402.json
+1755013404.json
+1755013559.json
+1755013561.json
+1755013568.json
+1755013570.json
+1755013808.json
+1755013810.json
+1755013894.json
+1755013896.json
+1755013931.json
+1755013932.json
+1755014194.json
+1755014195.json
+1755014215.json
+1755014217.json
+1755014288.json
+1755014290.json
+1755014507.json
+1755014588.json
+1755014631.json
+1755014660.json
+1755016785.json
+1755016787.json
+1755016850.json
+1755016852.json
+1755017040.json
+1755017042.json
+1755017123.json
+1755017146.json
+1755017185.json
+1755017208.json
+1755017225.json
+1755017451.json
+1755017453.json
+1755017564.json
+1755017566.json
+1755017649.json
+1755017650.json
+1755017673.json
+1755017674.json
+1755017942.json
+1755017943.json
+1755017978.json
+1755017979.json
+1755017988.json
+1755017990.json
+1755017998.json
+1755017999.json
+1755018011.json
+1755018013.json
+1755018023.json
+1755018025.json
+1755018033.json
+1755018035.json
+1755018043.json
+1755018045.json
+1755018053.json
+1755018055.json
+1755018064.json
+1755018065.json
+1755018073.json
+1755018075.json
+1755018083.json
+1755018085.json
+1755018092.json
+1755018094.json
+1755018105.json
+1755018106.json
+1755018118.json
+1755018120.json
+1755018128.json
+1755018130.json
+1755018137.json
+1755018139.json
+1755018148.json
+1755018150.json
+1755018157.json
+1755018159.json
+1755018166.json
+1755018168.json
+1755018177.json
+1755018178.json
+1755018186.json
+1755018188.json
+1755018198.json
+1755018200.json
+1755018207.json
+1755018209.json
+1755018217.json
+1755018218.json
+1755018230.json
+1755018232.json
+1755018323.json
+1755018325.json
+1755019354.json
+1755019356.json
+1755019471.json
+1755019472.json
+1755019512.json
+1755019514.json
+1755019853.json
+1755019854.json
+1755019928.json
+1755019930.json
+1755020218.json
+1755020220.json
+1755020245.json
+1755020247.json
+1755021412.json
+1755021414.json
+1755021578.json
+1755021803.json
+1755021805.json
+1755022444.json
+1755022446.json
+1755022457.json
+1755022458.json
+1755022478.json
+1755022479.json
+1755022494.json
+1755022496.json
+1755022609.json
+1755022611.json
+1755022624.json
+1755022626.json
+1755022672.json
+1755022674.json
+1755022815.json
+1755022817.json
+1755023010.json
+1755023012.json
+1755023049.json
+1755023051.json
+1755023322.json
+1755023323.json
+1755023377.json
+1755023379.json
+1755023392.json
+1755023394.json
+1755023408.json
+1755023410.json
+1755023445.json
+1755023447.json
+1755023471.json
+1755023472.json
+1755023481.json
+1755023482.json
+1755023491.json
+1755023493.json
+1755023516.json
+1755023518.json
+1755023526.json
+1755023528.json
+1755023540.json
+1755023542.json
+1755023586.json
+1755023588.json
+1755023595.json
+1755023597.json
+1755023619.json
+1755023620.json
+1755023631.json
+1755023632.json
+1755023643.json
+1755023645.json
+1755023674.json
+1755023676.json
+1755023683.json
+1755023685.json
+1755023693.json
+1755023694.json
+1755023719.json
+1755023721.json
+1755023727.json
+1755023729.json
+1755023744.json
+1755023746.json
+1755023767.json
+1755023769.json
+1755023893.json
+1755023895.json
+1755023906.json
+1755023908.json
+1755023917.json
+1755023919.json
+1755024002.json
+1755024003.json
+1755024070.json
+1755024072.json
+1755024079.json
+1755024081.json
+1755024237.json
+1755024239.json
+1755024349.json
+1755024351.json
+1755024418.json
+1755024419.json
+1755024432.json
+1755024434.json
+1755024546.json
+1755024548.json
+1755024563.json
+1755024565.json
+1755024638.json
+1755024640.json
+1755024713.json
+1755024715.json
+1755024883.json
+1755024885.json
+1755024894.json
+1755024896.json
+1755024905.json
+1755024907.json
+1755025147.json
+1755025186.json
+1755025188.json
+1755025222.json
+1755025224.json
+1755025261.json
+1755025263.json
+1755025277.json
+1755025279.json
+1755025285.json
+1755025287.json
+1755025328.json
+1755025330.json
+1755025483.json
+1755025485.json
+1755025517.json
+1755025534.json
+1755025542.json
+1755025552.json
+1755025554.json
+1755025598.json
+1755025600.json
+1755025625.json
+1755025656.json
+1755025693.json
+1755025720.json
+1755025736.json
+1755025810.json
+1755025815.json
+1755025929.json
+1755025976.json
+1755025978.json
+1755026000.json
+1755026002.json
+1755026016.json
+1755026018.json
+1755026056.json
+1755026191.json
+1755026218.json
+1755026219.json
+1755026317.json
+1755026319.json
+1755026398.json
+1755026404.json
+1755026729.json
+1755026731.json
+1755026744.json
+1755026746.json
+1755026766.json
+1755026768.json
+1755026989.json
+1755026991.json
+1755027076.json
+1755027078.json
+1755027088.json
+1755027090.json
+1755027251.json
+1755027252.json
+1755027264.json
+1755027266.json
+1755027274.json
+1755027276.json
+1755027289.json
+1755027291.json
+1755027468.json
+1755027470.json
+1755027489.json
+1755027491.json
+1755027511.json
+1755027513.json
+1755027726.json
+1755027728.json
+1755027741.json
+1755027743.json
+1755027774.json
+1755027776.json
+1755027820.json
+1755027822.json
+1755027874.json
+1755027876.json
+1755027894.json
+1755027896.json
+1755027917.json
+1755027919.json
+1755027969.json
+1755027972.json
+1755028187.json
+1755028189.json
+1755028246.json
+1755028247.json
+1755028317.json
+1755028319.json
+1755028421.json
+1755028422.json
+1755028513.json
+1755028514.json
+1755028580.json
+1755028582.json
+1755028636.json
+1755028638.json
+1755028652.json
+1755028653.json
+1755028670.json
+1755028672.json
+1755028692.json
+1755028694.json
+1755036212.json
+1755036215.json
+1755036250.json
+1755036252.json
+1755036713.json
+1755036715.json
+1755036930.json
+1755036932.json
+1755036949.json
+1755036950.json
+1755036977.json
+1755036978.json
+1755036990.json
+1755036991.json
+1755037019.json
+1755037021.json
+1755038007.json
+1755038009.json
+1755038084.json
+1755038086.json
+task-1754966099.json
+task-1755008137.json
+task-1755008271.json
+task-1755008660.json
+task-1755008900.json
+task-1755009103.json
+task-1755009368.json
+task-1755009415.json
+task-1755009426.json
+task-1755009482.json
+task-1755010109.json
+task-1755010637.json
+task-1755010833.json
+task-1755010934.json
+task-1755011155.json
+task-1755011183.json
+task-1755011219.json
+task-1755011239.json
+task-1755011415.json
+task-1755012643.json
+task-1755012772.json
+task-1755013067.json
+task-1755013154.json
+task-1755013256.json
+task-1755013542.json
+task-1755013620.json
+task-1755013667.json
+task-1755013749.json
+task-1755013978.json
+task-1755014033.json
+task-1755014111.json
+task-1755014421.json
+task-1755015379.json
+task-1755016645.json
+task-1755016823.json
+task-1755017060.json
+task-1755017274.json
+task-1755017915.json
+task-1755018858.json
+task-1755019061.json
+task-1755019793.json
+task-1755020170.json
+task-1755020389.json
+task-1755020823.json
+task-1755021335.json
+task-1755021476.json
+task-1755021716.json
+task-1755021890.json
+task-1755022420.json
+task-1755022760.json
+task-1755022914.json
+task-1755023040.json
+task-1755023280.json
+task-1755023796.json
+task-1755023819.json
+task-1755023932.json
+task-1755024196.json
+task-1755024220.json
+task-1755024384.json
+task-1755024948.json
+task-1755024979.json
+task-1755024998.json
+task-1755025018.json
+task-1755025117.json
+task-1755025208.json
+task-1755025243.json
+task-1755025349.json
+task-1755025374.json
+task-1755025379.json
+task-1755025382.json
+task-1755025384.json
+task-1755025402.json
+task-1755025570.json
+task-1755025614.json
+task-1755025647.json
+task-1755025667.json
+task-1755025932.json
+task-1755026045.json
+task-1755026051.json
+task-1755026064.json
+task-1755026105.json
+task-1755026188.json
+task-1755026203.json
+task-1755026233.json
+task-1755026243.json
+task-1755026344.json
+task-1755026353.json
+task-1755026394.json
+task-1755026417.json
+task-1755026428.json
+task-1755026695.json
+task-1755026957.json
+task-1755027224.json
+task-1755027440.json
+task-1755027646.json
+task-1755027935.json
+task-1755028148.json
+task-1755028616.json
+task-1755036055.json
+task-1755036596.json
+task-1755036900.json
+task-1755037864.json
+
+## Files Modified
+.claude-flow/metrics/performance.json
+.claude-flow/metrics/system-metrics.json
+.claude-flow/metrics/task-metrics.json
+.claude-flow/sessions/pair/pair_1755036279779.json
+.claude-flow/sessions/pair/pair_1755036289739.json
+.claude-flow/sessions/pair/pair_1755036300584.json
+.claude-flow/sessions/pair/pair_1755036558000.json
+.claude-flow/sessions/pair/pair_1755036569541.json
+.claude-flow/sessions/pair/pair_1755036726497.json
+.claude-flow/sessions/pair/pair_1755036736164.json
+.claude-flow/sessions/pair/pair_1755036864486.json
+.claude-flow/sessions/pair/pair_1755038032183.json
+.claude-flow/sessions/pair/pair_1755038043176.json
+.claude/checkpoints/1755036212.json
+.claude/checkpoints/1755036215.json
+.claude/checkpoints/1755036250.json
+.claude/checkpoints/1755036252.json
+.claude/checkpoints/1755036713.json
+.claude/checkpoints/1755036715.json
+.claude/checkpoints/1755036930.json
+.claude/checkpoints/1755036932.json
+.claude/checkpoints/1755036949.json
+.claude/checkpoints/1755036950.json
+.claude/checkpoints/1755036977.json
+.claude/checkpoints/1755036978.json
+.claude/checkpoints/1755036990.json
+.claude/checkpoints/1755036991.json
+.claude/checkpoints/1755037019.json
+.claude/checkpoints/1755037021.json
+.claude/checkpoints/1755038007.json
+.claude/checkpoints/1755038009.json
+.claude/checkpoints/summary-session-20250812-220533.md
+.claude/checkpoints/summary-session-20250812-221314.md
+.claude/checkpoints/summary-session-20250812-221712.md
+.claude/checkpoints/task-1755036055.json
+.claude/checkpoints/task-1755036596.json
+.claude/checkpoints/task-1755036900.json
+.claude/checkpoints/task-1755037864.json
+CHANGELOG.md
+bin/claude-flow
+claude-flow-wiki
+docs/pair-optimization.md
+issues/pair-command-fix.md
+src/cli/command-registry.js
+src/cli/simple-commands/pair-old.js
+src/cli/simple-commands/pair.js
+
+## Recent Commits
+f63c6f8c πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/docs/pair-optimization.md
+62948b04 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/pair-optimized.js
+d9fd33c9 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/issues/pair-command-fix.md
+11524141 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/CHANGELOG.md
+637e7a26 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/CHANGELOG.md
+2ee08e3b πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/CHANGELOG.md
+045a6bb3 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/CHANGELOG.md
+c1e64020 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/pair.js
+3338acea πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/command-registry.js
+14e21772 πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/pair.js
+
+## GitHub Releases Created
+No GitHub releases
+
+## Rollback Instructions
+To rollback to a specific checkpoint:
+```bash
+# List all checkpoints
+git tag -l checkpoint-* | sort -r
+
+# List GitHub releases
+gh release list
+
+# Rollback to a checkpoint
+git checkout checkpoint-YYYYMMDD-HHMMSS
+```
diff --git a/src/cli/simple-commands/pair-optimized.js b/src/cli/simple-commands/pair-optimized.js
deleted file mode 100644
index 9e9f1e60fe..0000000000
--- a/src/cli/simple-commands/pair-optimized.js
+++ /dev/null
@@ -1,732 +0,0 @@
-/**
- * Optimized Pair Programming Command
- * Interactive pair programming with intelligent verification
- */
-
-import fs from 'fs/promises';
-import path from 'path';
-import { spawn, exec } from 'child_process';
-import { promisify } from 'util';
-import readline from 'readline';
-import { watch } from 'fs';
-
-const execAsync = promisify(exec);
-
-class PairProgrammingSession {
- constructor(options = {}) {
- this.sessionId = `pair_${Date.now()}`;
- this.mode = options.mode || 'switch';
- this.agent = options.agent || 'auto';
- this.verify = options.verify || false;
- this.test = options.test || false;
- this.autoVerify = options.autoVerify || false; // New: control automatic verification
- this.threshold = options.threshold || 0.95;
- this.startTime = new Date();
- this.status = 'active';
- this.currentRole = 'driver';
- this.verificationScores = [];
- this.testResults = [];
- this.fileWatchers = new Map();
- this.rl = null;
- this.lastVerificationTime = 0;
- this.verificationCooldown = 60000; // 1 minute cooldown between auto-verifications
- this.isVerifying = false; // Prevent concurrent verifications
- }
-
- async start() {
- await this.saveSession();
- this.showWelcome();
-
- if (this.verify) {
- this.showVerificationSettings();
-
- // Only run initial verification once
- if (this.autoVerify) {
- console.log('\nπŸ” Running initial verification...');
- await this.runVerification();
- }
- }
-
- if (this.test) {
- await this.setupTestWatcher();
- }
-
- await this.startInteractiveMode();
- }
-
- showWelcome() {
- console.log('\nπŸš€ Starting Pair Programming Session');
- console.log('━'.repeat(50));
- console.log(`Session ID: ${this.sessionId}`);
- console.log(`Mode: ${this.mode}`);
- console.log(`Agent: ${this.agent}`);
- console.log(`Verification: ${this.verify ? 'βœ… Enabled' : '❌ Disabled'}`);
- console.log(`Auto-Verify: ${this.autoVerify ? 'βœ… Enabled' : '❌ Disabled'}`);
- console.log(`Testing: ${this.test ? 'βœ… Enabled' : '❌ Disabled'}`);
- console.log('━'.repeat(50));
-
- // Show mode details
- switch (this.mode) {
- case 'driver':
- console.log('\nπŸ‘€ You are the DRIVER - Write code while AI assists');
- console.log('πŸ€– AI is the NAVIGATOR - Providing guidance and suggestions');
- break;
- case 'navigator':
- console.log('\nπŸ€– AI is the DRIVER - Writing code based on your guidance');
- console.log('πŸ‘€ You are the NAVIGATOR - Providing high-level direction');
- break;
- case 'switch':
- console.log('\nπŸ”„ SWITCH MODE - Roles alternate every 10 minutes');
- console.log(`πŸ‘€ Current role: ${this.currentRole.toUpperCase()} (you)`);
- console.log('πŸ€– AI role: ' + (this.currentRole === 'driver' ? 'NAVIGATOR' : 'DRIVER'));
- this.startRoleTimer();
- break;
- }
-
- this.showCommands();
- }
-
- showCommands() {
- console.log('\nπŸ“ Session Commands:');
- console.log(' /help - Show available commands');
- console.log(' /switch - Switch driver/navigator roles');
- console.log(' /suggest - Get AI suggestions');
- console.log(' /review - Request code review');
- console.log(' /test - Run tests manually');
- console.log(' /verify - Run verification check');
- console.log(' /status - Show session status');
- console.log(' /metrics - Show quality metrics');
- console.log(' /auto - Toggle auto-verification');
- console.log(' /watch - Toggle file watching');
- console.log(' /commit - Commit with verification');
- console.log(' /end - End session');
- console.log(' /exit - Exit (same as /end)');
- }
-
- showVerificationSettings() {
- console.log('\nβœ… Verification Settings:');
- console.log(` β€’ Threshold: ${this.threshold}`);
- console.log(` β€’ Auto-verify: ${this.autoVerify ? 'Enabled' : 'Disabled'}`);
- console.log(` β€’ Manual verify: Always available via /verify`);
-
- if (this.autoVerify) {
- console.log(` β€’ Cooldown: ${this.verificationCooldown / 1000}s between checks`);
- console.log(' β€’ Use /auto to toggle automatic verification');
- }
- }
-
- async runVerification() {
- // Prevent concurrent verifications
- if (this.isVerifying) {
- console.log('⏳ Verification already in progress...');
- return null;
- }
-
- // Check cooldown for automatic verifications
- const now = Date.now();
- if (this.autoVerify && (now - this.lastVerificationTime) < this.verificationCooldown) {
- const remaining = Math.ceil((this.verificationCooldown - (now - this.lastVerificationTime)) / 1000);
- console.log(`⏱️ Verification cooldown: ${remaining}s remaining`);
- return null;
- }
-
- this.isVerifying = true;
- this.lastVerificationTime = now;
-
- console.log('\nπŸ” Running verification check...');
-
- const checks = [
- {
- name: 'Type Check',
- command: 'npm run typecheck 2>&1 || true',
- weight: 0.4 // Higher weight for type checking
- },
- {
- name: 'Linting',
- command: 'npm run lint 2>&1 || true',
- weight: 0.3
- },
- {
- name: 'Build',
- command: 'npm run build 2>&1 || true',
- weight: 0.3
- }
- ];
-
- let totalScore = 0;
- let totalWeight = 0;
- const results = [];
-
- for (const check of checks) {
- try {
- const { stdout, stderr } = await execAsync(check.command);
- const output = stdout + stderr;
-
- // More intelligent scoring based on actual output
- let score = 1.0;
-
- if (output.toLowerCase().includes('error')) {
- const errorCount = (output.match(/error/gi) || []).length;
- score = Math.max(0.2, 1.0 - (errorCount * 0.1)); // Deduct 0.1 per error, minimum 0.2
- } else if (output.toLowerCase().includes('warning')) {
- const warningCount = (output.match(/warning/gi) || []).length;
- score = Math.max(0.7, 1.0 - (warningCount * 0.05)); // Deduct 0.05 per warning, minimum 0.7
- }
-
- totalScore += score * check.weight;
- totalWeight += check.weight;
-
- const icon = score >= 0.8 ? 'βœ…' : score >= 0.5 ? '⚠️' : '❌';
- console.log(` ${icon} ${check.name}: ${score.toFixed(2)}`);
-
- results.push({ name: check.name, score, output: output.slice(0, 200) });
- } catch (error) {
- console.log(` ❌ ${check.name}: 0.00 (failed to run)`);
- results.push({ name: check.name, score: 0, error: error.message });
- totalWeight += check.weight;
- }
- }
-
- const averageScore = totalWeight > 0 ? totalScore / totalWeight : 0;
- this.verificationScores.push({ score: averageScore, timestamp: now, results });
-
- console.log(`\nπŸ“Š Verification Score: ${averageScore.toFixed(2)}/${this.threshold}`);
-
- if (averageScore < this.threshold) {
- console.log('⚠️ Verification threshold not met');
-
- // Only show detailed help if score is very low
- if (averageScore < 0.5) {
- console.log('\nπŸ’‘ Suggestions:');
- console.log(' β€’ Run /test to check test failures');
- console.log(' β€’ Check TypeScript errors with npm run typecheck');
- console.log(' β€’ Fix linting issues with npm run lint --fix');
- }
- } else {
- console.log('βœ… Verification passed!');
- }
-
- this.isVerifying = false;
- return averageScore;
- }
-
- async setupTestWatcher() {
- console.log('\nπŸ§ͺ Test Configuration:');
- console.log(' β€’ Manual testing via /test command');
- console.log(' β€’ File watching available via /watch');
-
- // Don't automatically run tests, wait for user command
- }
-
- async runTests() {
- console.log('\nπŸ§ͺ Running tests...');
-
- try {
- const { stdout, stderr } = await execAsync('npm test 2>&1 || true');
- const output = stdout + stderr;
- const lines = output.split('\n');
-
- // Parse test results more intelligently
- const passLine = lines.find(l => l.includes('passed'));
- const failLine = lines.find(l => l.includes('failed'));
- const suitesLine = lines.find(l => l.includes('Test Suites:'));
-
- let passed = false;
- let summary = 'No test results found';
-
- if (suitesLine) {
- summary = suitesLine.trim();
- passed = !suitesLine.includes('failed');
- } else if (passLine || failLine) {
- summary = (passLine || failLine).trim();
- passed = !!passLine && !failLine;
- }
-
- console.log(` ${passed ? 'βœ…' : '❌'} ${summary}`);
-
- // Extract coverage if available
- const coverageLine = lines.find(l => l.includes('Coverage') || l.includes('Statements'));
- if (coverageLine) {
- console.log(` πŸ“Š ${coverageLine.trim()}`);
- }
-
- this.testResults.push({
- timestamp: new Date(),
- passed,
- summary
- });
-
- return passed;
- } catch (error) {
- console.log(' ❌ Test execution failed:', error.message);
- return false;
- }
- }
-
- startRoleTimer() {
- if (this.mode !== 'switch') return;
-
- this.roleTimer = setTimeout(() => {
- this.switchRoles();
- this.startRoleTimer(); // Restart timer
- }, 10 * 60 * 1000); // 10 minutes
- }
-
- switchRoles() {
- const oldRole = this.currentRole;
- this.currentRole = this.currentRole === 'driver' ? 'navigator' : 'driver';
-
- console.log('\nπŸ”„ Role Switch!');
- console.log(` Previous role: ${oldRole.toUpperCase()}`);
- console.log(` New role: ${this.currentRole.toUpperCase()}`);
- console.log(' Take a moment to transition...\n');
- }
-
- async startInteractiveMode() {
- this.rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout,
- prompt: '\nπŸ’» pair> '
- });
-
- console.log('\nπŸ’‘ Interactive mode active. Type /help for commands.\n');
-
- this.rl.prompt();
-
- this.rl.on('line', async (line) => {
- const input = line.trim();
-
- if (input.startsWith('/')) {
- await this.handleCommand(input);
- } else if (input) {
- // Handle regular input as code discussion
- console.log('πŸ€– AI: Processing your input...');
- // In a real implementation, this would send to AI
- }
-
- this.rl.prompt();
- });
-
- this.rl.on('close', () => {
- this.end();
- });
- }
-
- async handleCommand(command) {
- const [cmd, ...args] = command.split(' ');
-
- switch (cmd) {
- case '/help':
- this.showCommands();
- break;
-
- case '/switch':
- this.switchRoles();
- break;
-
- case '/suggest':
- console.log('πŸ€– AI Suggestion: Consider using async/await for better readability');
- console.log(' Also check error handling in promise chains');
- break;
-
- case '/review':
- console.log('πŸ” Starting code review...');
- await this.runVerification();
- break;
-
- case '/test':
- await this.runTests();
- break;
-
- case '/verify':
- await this.runVerification();
- break;
-
- case '/status':
- await this.showStatus();
- break;
-
- case '/metrics':
- this.showMetrics();
- break;
-
- case '/auto':
- this.autoVerify = !this.autoVerify;
- console.log(`\nπŸ”„ Auto-verification ${this.autoVerify ? 'enabled' : 'disabled'}`);
- if (this.autoVerify) {
- console.log(` Cooldown: ${this.verificationCooldown / 1000}s between checks`);
- }
- break;
-
- case '/watch':
- console.log('πŸ“‚ File watching not yet implemented');
- console.log(' Use /verify or /test for manual checks');
- break;
-
- case '/commit':
- await this.commitWithVerification();
- break;
-
- case '/end':
- case '/exit':
- await this.end();
- process.exit(0);
- break;
-
- default:
- console.log(`❌ Unknown command: ${cmd}`);
- console.log('πŸ’‘ Type /help for available commands');
- }
- }
-
- async showStatus() {
- const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
-
- console.log('\nπŸ“Š Session Status');
- console.log('━'.repeat(40));
- console.log(`Session ID: ${this.sessionId}`);
- console.log(`Duration: ${duration} minutes`);
- console.log(`Current Role: ${this.currentRole.toUpperCase()}`);
- console.log(`Mode: ${this.mode}`);
- console.log(`Status: ${this.status}`);
- console.log(`Auto-Verify: ${this.autoVerify ? 'Enabled' : 'Disabled'}`);
-
- if (this.verify && this.verificationScores.length > 0) {
- const recent = this.verificationScores[this.verificationScores.length - 1];
- console.log(`Last Verification: ${recent.score.toFixed(2)} (${new Date(recent.timestamp).toLocaleTimeString()})`);
- }
-
- if (this.test && this.testResults.length > 0) {
- const passed = this.testResults.filter(r => r.passed).length;
- console.log(`Tests Passed: ${passed}/${this.testResults.length}`);
- }
- }
-
- showMetrics() {
- console.log('\nπŸ“ˆ Quality Metrics');
- console.log('━'.repeat(40));
-
- if (this.verificationScores.length > 0) {
- console.log('\nVerification History:');
- this.verificationScores.slice(-5).forEach((item, i) => {
- const bar = 'β–ˆ'.repeat(Math.floor(item.score * 20));
- const time = new Date(item.timestamp).toLocaleTimeString();
- console.log(` ${i + 1}. ${bar} ${item.score.toFixed(2)} - ${time}`);
- });
-
- // Show average
- const avg = this.verificationScores.reduce((sum, item) => sum + item.score, 0) / this.verificationScores.length;
- console.log(`\n Average: ${avg.toFixed(2)}`);
- } else {
- console.log('\n No verification history yet');
- console.log(' Run /verify to check code quality');
- }
-
- if (this.testResults.length > 0) {
- console.log('\nTest Results:');
- this.testResults.slice(-5).forEach((result, i) => {
- console.log(` ${i + 1}. ${result.passed ? 'βœ…' : '❌'} ${new Date(result.timestamp).toLocaleTimeString()}`);
- });
-
- // Show success rate
- const passed = this.testResults.filter(r => r.passed).length;
- const rate = (passed / this.testResults.length * 100).toFixed(0);
- console.log(`\n Success Rate: ${rate}%`);
- } else {
- console.log('\n No test history yet');
- console.log(' Run /test to execute test suite');
- }
- }
-
- async commitWithVerification() {
- console.log('\nπŸ” Pre-commit verification...');
-
- const score = await this.runVerification();
-
- if (score === null) {
- console.log('⏳ Please wait for cooldown or use /verify manually');
- return;
- }
-
- if (score >= this.threshold) {
- console.log('βœ… Verification passed! Ready to commit.');
- console.log('\nπŸ’‘ Next steps:');
- console.log(' 1. Review changes: git diff');
- console.log(' 2. Stage files: git add .');
- console.log(' 3. Commit: git commit -m "your message"');
- } else {
- console.log('❌ Verification failed!');
- console.log('\nπŸ’‘ Fix issues before committing:');
- console.log(' β€’ Run npm run typecheck to see TypeScript errors');
- console.log(' β€’ Run npm run lint to check code style');
- console.log(' β€’ Run npm run build to verify compilation');
- }
- }
-
- async end() {
- console.log('\nπŸ›‘ Ending pair programming session...');
-
- // Clear timers
- if (this.roleTimer) clearTimeout(this.roleTimer);
- if (this.rl) this.rl.close();
-
- // Update session
- this.status = 'completed';
- await this.saveSession();
-
- // Show summary
- const duration = Math.floor((Date.now() - this.startTime) / 1000 / 60);
- console.log('\n✨ Session Complete!');
- console.log('━'.repeat(40));
- console.log(`Duration: ${duration} minutes`);
-
- if (this.verificationScores.length > 0) {
- const avg = this.verificationScores.reduce((sum, item) => sum + item.score, 0) / this.verificationScores.length;
- console.log(`Average Verification: ${avg.toFixed(2)}`);
- console.log(`Total Checks: ${this.verificationScores.length}`);
- }
-
- if (this.testResults.length > 0) {
- const passed = this.testResults.filter(r => r.passed).length;
- console.log(`Test Success Rate: ${((passed / this.testResults.length) * 100).toFixed(0)}%`);
- console.log(`Total Test Runs: ${this.testResults.length}`);
- }
-
- console.log('\nπŸ‘‹ Thanks for pair programming!\n');
- }
-
- async saveSession() {
- const sessionPath = '.claude-flow/sessions/pair';
- await fs.mkdir(sessionPath, { recursive: true });
-
- const sessionData = {
- id: this.sessionId,
- mode: this.mode,
- agent: this.agent,
- verify: this.verify,
- autoVerify: this.autoVerify,
- test: this.test,
- threshold: this.threshold,
- startTime: this.startTime.toISOString(),
- status: this.status,
- currentRole: this.currentRole,
- verificationScores: this.verificationScores,
- testResults: this.testResults
- };
-
- await fs.writeFile(
- path.join(sessionPath, `${this.sessionId}.json`),
- JSON.stringify(sessionData, null, 2)
- );
- }
-}
-
-async function pairCommand(args = [], flags = {}) {
- console.log('\nπŸ‘₯ Pair Programming Session');
- console.log('━'.repeat(50));
-
- // Handle help flag
- if (flags.help || args.includes('--help')) {
- showHelp();
- return;
- }
-
- // Handle background execution
- if (flags.background || flags.bg) {
- return startBackgroundSession(args, flags);
- }
-
- // Handle start flag
- if (flags.start) {
- const session = new PairProgrammingSession({
- mode: flags.mode || 'switch',
- agent: flags.agent || 'auto',
- verify: flags.verify || false,
- test: flags.test || false,
- autoVerify: flags.auto || false, // New flag for automatic verification
- threshold: parseFloat(flags.threshold) || 0.95
- });
-
- return await session.start();
- }
-
- // Handle status flag
- if (flags.status) {
- return showSessionStatus();
- }
-
- // Handle end flag
- if (flags.end) {
- return endSession(flags.sessionId || 'current');
- }
-
- // Default: show help
- showHelp();
-}
-
-function showHelp() {
- console.log(`
-πŸ“š USAGE:
- claude-flow pair [options]
-
-βš™οΈ OPTIONS:
- --start Start a new pair programming session
- --end End current session
- --status Show session status
- --mode <type> Programming mode: driver, navigator, switch (default: switch)
- --agent <name> AI pair partner (default: auto-select)
- --verify Enable verification (manual via /verify)
- --auto Enable automatic verification (with cooldown)
- --test Enable testing (manual via /test)
- --threshold <n> Verification threshold (default: 0.95)
- --background, --bg Run in background
- --help Show this help message
-
-πŸ“ MODES:
- driver You write code, AI assists
- navigator AI writes code, you guide
- switch Automatically alternate roles every 10 minutes
-
-🎯 SESSION COMMANDS:
- /help Show available commands
- /switch Switch driver/navigator roles
- /suggest Get AI suggestions
- /review Request code review
- /test Run tests manually
- /verify Run verification check
- /status Show session status
- /metrics Show quality metrics
- /auto Toggle auto-verification
- /watch Toggle file watching
- /commit Commit with verification
- /end End session
-
-πŸ’‘ EXAMPLES:
- # Basic session with manual verification
- claude-flow pair --start --verify
-
- # Session with automatic verification (60s cooldown)
- claude-flow pair --start --verify --auto
-
- # Driver mode with testing
- claude-flow pair --start --mode driver --test
-
- # Check session status
- claude-flow pair --status
-
-🎯 OPTIMIZATION TIPS:
- β€’ Use /verify manually when needed
- β€’ Enable --auto only for continuous monitoring
- β€’ Use /metrics to track quality trends
- β€’ Run /test before commits
-
-πŸ“š For detailed documentation, see:
- .claude/commands/pair/README.md
-`);
-}
-
-async function startBackgroundSession(args, flags) {
- console.log('\nπŸ”„ Starting pair session in background...');
-
- const child = spawn(process.argv[0], [
- process.argv[1],
- 'pair',
- '--start',
- ...args.filter(arg => arg !== '--background' && arg !== '--bg')
- ], {
- detached: true,
- stdio: 'ignore'
- });
-
- child.unref();
-
- const pid = child.pid;
- console.log(`βœ… Background session started (PID: ${pid})`);
- console.log('\nπŸ“Š Monitor with: claude-flow pair --status');
- console.log('πŸ›‘ Stop with: claude-flow pair --end\n');
-}
-
-async function showSessionStatus() {
- try {
- const sessionPath = '.claude-flow/sessions/pair';
- const files = await fs.readdir(sessionPath);
- const sessions = [];
-
- for (const file of files) {
- if (file.endsWith('.json')) {
- const data = await fs.readFile(path.join(sessionPath, file), 'utf8');
- sessions.push(JSON.parse(data));
- }
- }
-
- if (sessions.length === 0) {
- console.log('\n❌ No active pair programming sessions\n');
- return;
- }
-
- console.log('\nπŸ“Š Pair Programming Sessions:');
- console.log('━'.repeat(50));
-
- for (const session of sessions.filter(s => s.status === 'active')) {
- const duration = Math.floor((Date.now() - new Date(session.startTime).getTime()) / 1000 / 60);
- console.log(`\nπŸ”Ή Session: ${session.id}`);
- console.log(` Mode: ${session.mode}`);
- console.log(` Duration: ${duration} minutes`);
- console.log(` Status: ${session.status}`);
- console.log(` Verification: ${session.verify ? 'βœ…' : '❌'}`);
- console.log(` Auto-Verify: ${session.autoVerify ? 'βœ…' : '❌'}`);
- console.log(` Testing: ${session.test ? 'βœ…' : '❌'}`);
-
- if (session.verificationScores && session.verificationScores.length > 0) {
- const scores = session.verificationScores.map(s => s.score || s);
- const avg = scores.reduce((a, b) => a + b, 0) / scores.length;
- console.log(` Avg Verification: ${avg.toFixed(2)}`);
- console.log(` Total Checks: ${scores.length}`);
- }
- }
-
- console.log('━'.repeat(50));
- } catch (error) {
- console.log('\n❌ No active pair programming sessions\n');
- }
-}
-
-async function endSession(sessionId) {
- console.log(`\nπŸ›‘ Ending pair programming session: ${sessionId}`);
-
- try {
- const sessionPath = '.claude-flow/sessions/pair';
-
- if (sessionId === 'current') {
- // End most recent active session
- const files = await fs.readdir(sessionPath);
- for (const file of files.filter(f => f.endsWith('.json'))) {
- const data = await fs.readFile(path.join(sessionPath, file), 'utf8');
- const session = JSON.parse(data);
- if (session.status === 'active') {
- sessionId = session.id;
- break;
- }
- }
- }
-
- const sessionFile = path.join(sessionPath, `${sessionId}.json`);
- const data = await fs.readFile(sessionFile, 'utf8');
- const session = JSON.parse(data);
-
- session.status = 'completed';
- session.endTime = new Date().toISOString();
-
- await fs.writeFile(sessionFile, JSON.stringify(session, null, 2));
-
- console.log('βœ… Session ended successfully');
- console.log(`\nπŸ“Š Session Summary:`);
- console.log(` Duration: ${Math.floor((new Date(session.endTime) - new Date(session.startTime)) / 1000 / 60)} minutes`);
- console.log(` Mode: ${session.mode}`);
- console.log(` Agent: ${session.agent}\n`);
- } catch (error) {
- console.log('❌ Failed to end session:', error.message);
- }
-}
-
-export default pairCommand;
\ No newline at end of file
diff --git a/src/cli/simple-commands/pair.js b/src/cli/simple-commands/pair.js
index 4e7401870d..9e9f1e60fe 100644
--- a/src/cli/simple-commands/pair.js
+++ b/src/cli/simple-commands/pair.js
@@ -1,6 +1,6 @@
/**
- * Pair Programming Command
- * Interactive pair programming with AI assistance and real-time verification
+ * Optimized Pair Programming Command
+ * Interactive pair programming with intelligent verification
*/
import fs from 'fs/promises';
@@ -8,6 +8,7 @@ import path from 'path';
import { spawn, exec } from 'child_process';
import { promisify } from 'util';
import readline from 'readline';
+import { watch } from 'fs';
const execAsync = promisify(exec);
@@ -18,6 +19,7 @@ class PairProgrammingSession {
this.agent = options.agent || 'auto';
this.verify = options.verify || false;
this.test = options.test || false;
+ this.autoVerify = options.autoVerify || false; // New: control automatic verification
this.threshold = options.threshold || 0.95;
this.startTime = new Date();
this.status = 'active';
@@ -26,6 +28,9 @@ class PairProgrammingSession {
this.testResults = [];
this.fileWatchers = new Map();
this.rl = null;
+ this.lastVerificationTime = 0;
+ this.verificationCooldown = 60000; // 1 minute cooldown between auto-verifications
+ this.isVerifying = false; // Prevent concurrent verifications
}
async start() {
@@ -33,11 +38,17 @@ class PairProgrammingSession {
this.showWelcome();
if (this.verify) {
- await this.startVerification();
+ this.showVerificationSettings();
+
+ // Only run initial verification once
+ if (this.autoVerify) {
+ console.log('\nπŸ” Running initial verification...');
+ await this.runVerification();
+ }
}
if (this.test) {
- await this.startTestWatcher();
+ await this.setupTestWatcher();
}
await this.startInteractiveMode();
@@ -50,6 +61,7 @@ class PairProgrammingSession {
console.log(`Mode: ${this.mode}`);
console.log(`Agent: ${this.agent}`);
console.log(`Verification: ${this.verify ? 'βœ… Enabled' : '❌ Disabled'}`);
+ console.log(`Auto-Verify: ${this.autoVerify ? 'βœ… Enabled' : '❌ Disabled'}`);
console.log(`Testing: ${this.test ? 'βœ… Enabled' : '❌ Disabled'}`);
console.log('━'.repeat(50));
@@ -84,112 +96,167 @@ class PairProgrammingSession {
console.log(' /verify - Run verification check');
console.log(' /status - Show session status');
console.log(' /metrics - Show quality metrics');
+ console.log(' /auto - Toggle auto-verification');
+ console.log(' /watch - Toggle file watching');
console.log(' /commit - Commit with verification');
console.log(' /end - End session');
console.log(' /exit - Exit (same as /end)');
}
- async startVerification() {
- console.log('\nβœ… Verification System Active');
+ showVerificationSettings() {
+ console.log('\nβœ… Verification Settings:');
console.log(` β€’ Threshold: ${this.threshold}`);
- console.log(' β€’ Real-time validation enabled');
- console.log(' β€’ Auto-rollback on failures');
+ console.log(` β€’ Auto-verify: ${this.autoVerify ? 'Enabled' : 'Disabled'}`);
+ console.log(` β€’ Manual verify: Always available via /verify`);
- // Start verification loop
- this.verificationInterval = setInterval(async () => {
- await this.runVerification();
- }, 30000); // Run every 30 seconds
+ if (this.autoVerify) {
+ console.log(` β€’ Cooldown: ${this.verificationCooldown / 1000}s between checks`);
+ console.log(' β€’ Use /auto to toggle automatic verification');
+ }
}
async runVerification() {
+ // Prevent concurrent verifications
+ if (this.isVerifying) {
+ console.log('⏳ Verification already in progress...');
+ return null;
+ }
+
+ // Check cooldown for automatic verifications
+ const now = Date.now();
+ if (this.autoVerify && (now - this.lastVerificationTime) < this.verificationCooldown) {
+ const remaining = Math.ceil((this.verificationCooldown - (now - this.lastVerificationTime)) / 1000);
+ console.log(`⏱️ Verification cooldown: ${remaining}s remaining`);
+ return null;
+ }
+
+ this.isVerifying = true;
+ this.lastVerificationTime = now;
+
console.log('\nπŸ” Running verification check...');
const checks = [
- { name: 'Type Check', command: 'npm run typecheck 2>&1 || true' },
- { name: 'Linting', command: 'npm run lint 2>&1 || true' },
- { name: 'Build', command: 'npm run build 2>&1 || true' }
+ {
+ name: 'Type Check',
+ command: 'npm run typecheck 2>&1 || true',
+ weight: 0.4 // Higher weight for type checking
+ },
+ {
+ name: 'Linting',
+ command: 'npm run lint 2>&1 || true',
+ weight: 0.3
+ },
+ {
+ name: 'Build',
+ command: 'npm run build 2>&1 || true',
+ weight: 0.3
+ }
];
let totalScore = 0;
- let passedChecks = 0;
+ let totalWeight = 0;
+ const results = [];
for (const check of checks) {
try {
- const { stdout } = await execAsync(check.command);
- const passed = !stdout.toLowerCase().includes('error');
- const score = passed ? 1.0 : 0.5;
+ const { stdout, stderr } = await execAsync(check.command);
+ const output = stdout + stderr;
+
+ // More intelligent scoring based on actual output
+ let score = 1.0;
- totalScore += score;
- if (passed) passedChecks++;
+ if (output.toLowerCase().includes('error')) {
+ const errorCount = (output.match(/error/gi) || []).length;
+ score = Math.max(0.2, 1.0 - (errorCount * 0.1)); // Deduct 0.1 per error, minimum 0.2
+ } else if (output.toLowerCase().includes('warning')) {
+ const warningCount = (output.match(/warning/gi) || []).length;
+ score = Math.max(0.7, 1.0 - (warningCount * 0.05)); // Deduct 0.05 per warning, minimum 0.7
+ }
+
+ totalScore += score * check.weight;
+ totalWeight += check.weight;
+
+ const icon = score >= 0.8 ? 'βœ…' : score >= 0.5 ? '⚠️' : '❌';
+ console.log(` ${icon} ${check.name}: ${score.toFixed(2)}`);
- console.log(` ${passed ? 'βœ…' : '⚠️'} ${check.name}: ${score.toFixed(2)}`);
+ results.push({ name: check.name, score, output: output.slice(0, 200) });
} catch (error) {
- console.log(` ❌ ${check.name}: 0.00 (failed)`);
+ console.log(` ❌ ${check.name}: 0.00 (failed to run)`);
+ results.push({ name: check.name, score: 0, error: error.message });
+ totalWeight += check.weight;
}
}
- const averageScore = totalScore / checks.length;
- this.verificationScores.push(averageScore);
+ const averageScore = totalWeight > 0 ? totalScore / totalWeight : 0;
+ this.verificationScores.push({ score: averageScore, timestamp: now, results });
console.log(`\nπŸ“Š Verification Score: ${averageScore.toFixed(2)}/${this.threshold}`);
if (averageScore < this.threshold) {
- console.log('⚠️ Verification threshold not met!');
- if (this.verify && averageScore < 0.7) {
- console.log('πŸ”„ Consider reverting recent changes');
+ console.log('⚠️ Verification threshold not met');
+
+ // Only show detailed help if score is very low
+ if (averageScore < 0.5) {
+ console.log('\nπŸ’‘ Suggestions:');
+ console.log(' β€’ Run /test to check test failures');
+ console.log(' β€’ Check TypeScript errors with npm run typecheck');
+ console.log(' β€’ Fix linting issues with npm run lint --fix');
}
} else {
console.log('βœ… Verification passed!');
}
+ this.isVerifying = false;
return averageScore;
}
- async startTestWatcher() {
- console.log('\nπŸ§ͺ Test Watcher Active');
- console.log(' β€’ Tests run on file changes');
- console.log(' β€’ Coverage tracking enabled');
-
- // Run initial test
- await this.runTests();
+ async setupTestWatcher() {
+ console.log('\nπŸ§ͺ Test Configuration:');
+ console.log(' β€’ Manual testing via /test command');
+ console.log(' β€’ File watching available via /watch');
- // Watch for file changes (simplified version)
- this.testInterval = setInterval(async () => {
- // In a real implementation, this would watch actual file changes
- // For now, we'll just run tests periodically during the session
- }, 60000); // Check every minute
+ // Don't automatically run tests, wait for user command
}
async runTests() {
console.log('\nπŸ§ͺ Running tests...');
try {
- const { stdout } = await execAsync('npm test 2>&1 || true');
- const lines = stdout.split('\n');
+ const { stdout, stderr } = await execAsync('npm test 2>&1 || true');
+ const output = stdout + stderr;
+ const lines = output.split('\n');
- // Parse test results
- const summaryLine = lines.find(l => l.includes('Tests:') || l.includes('PASS') || l.includes('FAIL'));
+ // Parse test results more intelligently
+ const passLine = lines.find(l => l.includes('passed'));
+ const failLine = lines.find(l => l.includes('failed'));
+ const suitesLine = lines.find(l => l.includes('Test Suites:'));
- if (summaryLine) {
- console.log(` ${summaryLine.trim()}`);
-
- // Extract coverage if available
- const coverageLine = lines.find(l => l.includes('Coverage'));
- if (coverageLine) {
- console.log(` ${coverageLine.trim()}`);
- }
-
- this.testResults.push({
- timestamp: new Date(),
- passed: stdout.includes('PASS'),
- summary: summaryLine
- });
-
- return stdout.includes('PASS');
- } else {
- console.log(' ⚠️ No test results found');
- return false;
+ let passed = false;
+ let summary = 'No test results found';
+
+ if (suitesLine) {
+ summary = suitesLine.trim();
+ passed = !suitesLine.includes('failed');
+ } else if (passLine || failLine) {
+ summary = (passLine || failLine).trim();
+ passed = !!passLine && !failLine;
}
+
+ console.log(` ${passed ? 'βœ…' : '❌'} ${summary}`);
+
+ // Extract coverage if available
+ const coverageLine = lines.find(l => l.includes('Coverage') || l.includes('Statements'));
+ if (coverageLine) {
+ console.log(` πŸ“Š ${coverageLine.trim()}`);
+ }
+
+ this.testResults.push({
+ timestamp: new Date(),
+ passed,
+ summary
+ });
+
+ return passed;
} catch (error) {
console.log(' ❌ Test execution failed:', error.message);
return false;
@@ -259,6 +326,7 @@ class PairProgrammingSession {
case '/suggest':
console.log('πŸ€– AI Suggestion: Consider using async/await for better readability');
+ console.log(' Also check error handling in promise chains');
break;
case '/review':
@@ -282,6 +350,19 @@ class PairProgrammingSession {
this.showMetrics();
break;
+ case '/auto':
+ this.autoVerify = !this.autoVerify;
+ console.log(`\nπŸ”„ Auto-verification ${this.autoVerify ? 'enabled' : 'disabled'}`);
+ if (this.autoVerify) {
+ console.log(` Cooldown: ${this.verificationCooldown / 1000}s between checks`);
+ }
+ break;
+
+ case '/watch':
+ console.log('πŸ“‚ File watching not yet implemented');
+ console.log(' Use /verify or /test for manual checks');
+ break;
+
case '/commit':
await this.commitWithVerification();
break;
@@ -308,10 +389,11 @@ class PairProgrammingSession {
console.log(`Current Role: ${this.currentRole.toUpperCase()}`);
console.log(`Mode: ${this.mode}`);
console.log(`Status: ${this.status}`);
+ console.log(`Auto-Verify: ${this.autoVerify ? 'Enabled' : 'Disabled'}`);
if (this.verify && this.verificationScores.length > 0) {
- const avgScore = this.verificationScores.reduce((a, b) => a + b, 0) / this.verificationScores.length;
- console.log(`Average Verification: ${avgScore.toFixed(2)}`);
+ const recent = this.verificationScores[this.verificationScores.length - 1];
+ console.log(`Last Verification: ${recent.score.toFixed(2)} (${new Date(recent.timestamp).toLocaleTimeString()})`);
}
if (this.test && this.testResults.length > 0) {
@@ -326,10 +408,18 @@ class PairProgrammingSession {
if (this.verificationScores.length > 0) {
console.log('\nVerification History:');
- this.verificationScores.slice(-5).forEach((score, i) => {
- const bar = 'β–ˆ'.repeat(Math.floor(score * 20));
- console.log(` ${i + 1}. ${bar} ${score.toFixed(2)}`);
+ this.verificationScores.slice(-5).forEach((item, i) => {
+ const bar = 'β–ˆ'.repeat(Math.floor(item.score * 20));
+ const time = new Date(item.timestamp).toLocaleTimeString();
+ console.log(` ${i + 1}. ${bar} ${item.score.toFixed(2)} - ${time}`);
});
+
+ // Show average
+ const avg = this.verificationScores.reduce((sum, item) => sum + item.score, 0) / this.verificationScores.length;
+ console.log(`\n Average: ${avg.toFixed(2)}`);
+ } else {
+ console.log('\n No verification history yet');
+ console.log(' Run /verify to check code quality');
}
if (this.testResults.length > 0) {
@@ -337,6 +427,14 @@ class PairProgrammingSession {
this.testResults.slice(-5).forEach((result, i) => {
console.log(` ${i + 1}. ${result.passed ? 'βœ…' : '❌'} ${new Date(result.timestamp).toLocaleTimeString()}`);
});
+
+ // Show success rate
+ const passed = this.testResults.filter(r => r.passed).length;
+ const rate = (passed / this.testResults.length * 100).toFixed(0);
+ console.log(`\n Success Rate: ${rate}%`);
+ } else {
+ console.log('\n No test history yet');
+ console.log(' Run /test to execute test suite');
}
}
@@ -345,20 +443,30 @@ class PairProgrammingSession {
const score = await this.runVerification();
+ if (score === null) {
+ console.log('⏳ Please wait for cooldown or use /verify manually');
+ return;
+ }
+
if (score >= this.threshold) {
console.log('βœ… Verification passed! Ready to commit.');
- console.log('πŸ’‘ Run: git commit -m "your message"');
+ console.log('\nπŸ’‘ Next steps:');
+ console.log(' 1. Review changes: git diff');
+ console.log(' 2. Stage files: git add .');
+ console.log(' 3. Commit: git commit -m "your message"');
} else {
- console.log('❌ Verification failed! Please fix issues before committing.');
+ console.log('❌ Verification failed!');
+ console.log('\nπŸ’‘ Fix issues before committing:');
+ console.log(' β€’ Run npm run typecheck to see TypeScript errors');
+ console.log(' β€’ Run npm run lint to check code style');
+ console.log(' β€’ Run npm run build to verify compilation');
}
}
async end() {
console.log('\nπŸ›‘ Ending pair programming session...');
- // Clear intervals
- if (this.verificationInterval) clearInterval(this.verificationInterval);
- if (this.testInterval) clearInterval(this.testInterval);
+ // Clear timers
if (this.roleTimer) clearTimeout(this.roleTimer);
if (this.rl) this.rl.close();
@@ -373,13 +481,15 @@ class PairProgrammingSession {
console.log(`Duration: ${duration} minutes`);
if (this.verificationScores.length > 0) {
- const avgScore = this.verificationScores.reduce((a, b) => a + b, 0) / this.verificationScores.length;
- console.log(`Average Verification: ${avgScore.toFixed(2)}`);
+ const avg = this.verificationScores.reduce((sum, item) => sum + item.score, 0) / this.verificationScores.length;
+ console.log(`Average Verification: ${avg.toFixed(2)}`);
+ console.log(`Total Checks: ${this.verificationScores.length}`);
}
if (this.testResults.length > 0) {
const passed = this.testResults.filter(r => r.passed).length;
console.log(`Test Success Rate: ${((passed / this.testResults.length) * 100).toFixed(0)}%`);
+ console.log(`Total Test Runs: ${this.testResults.length}`);
}
console.log('\nπŸ‘‹ Thanks for pair programming!\n');
@@ -394,6 +504,7 @@ class PairProgrammingSession {
mode: this.mode,
agent: this.agent,
verify: this.verify,
+ autoVerify: this.autoVerify,
test: this.test,
threshold: this.threshold,
startTime: this.startTime.toISOString(),
@@ -432,6 +543,7 @@ async function pairCommand(args = [], flags = {}) {
agent: flags.agent || 'auto',
verify: flags.verify || false,
test: flags.test || false,
+ autoVerify: flags.auto || false, // New flag for automatic verification
threshold: parseFloat(flags.threshold) || 0.95
});
@@ -463,8 +575,9 @@ function showHelp() {
--status Show session status
--mode <type> Programming mode: driver, navigator, switch (default: switch)
--agent <name> AI pair partner (default: auto-select)
- --verify Enable real-time verification
- --test Run tests after each change
+ --verify Enable verification (manual via /verify)
+ --auto Enable automatic verification (with cooldown)
+ --test Enable testing (manual via /test)
--threshold <n> Verification threshold (default: 0.95)
--background, --bg Run in background
--help Show this help message
@@ -483,19 +596,29 @@ function showHelp() {
/verify Run verification check
/status Show session status
/metrics Show quality metrics
+ /auto Toggle auto-verification
+ /watch Toggle file watching
/commit Commit with verification
/end End session
πŸ’‘ EXAMPLES:
- claude-flow pair --start
- claude-flow pair --start --mode driver --verify
- claude-flow pair --start --verify --test
- claude-flow pair --start --agent senior-dev --test
+ # Basic session with manual verification
+ claude-flow pair --start --verify
+
+ # Session with automatic verification (60s cooldown)
+ claude-flow pair --start --verify --auto
+
+ # Driver mode with testing
+ claude-flow pair --start --mode driver --test
+
+ # Check session status
claude-flow pair --status
- claude-flow pair --end
-🎯 QUICK START:
- npx claude-flow@alpha pair --start --verify --test
+🎯 OPTIMIZATION TIPS:
+ β€’ Use /verify manually when needed
+ β€’ Enable --auto only for continuous monitoring
+ β€’ Use /metrics to track quality trends
+ β€’ Run /test before commits
πŸ“š For detailed documentation, see:
.claude/commands/pair/README.md
@@ -548,15 +671,17 @@ async function showSessionStatus() {
const duration = Math.floor((Date.now() - new Date(session.startTime).getTime()) / 1000 / 60);
console.log(`\nπŸ”Ή Session: ${session.id}`);
console.log(` Mode: ${session.mode}`);
- console.log(` Agent: ${session.agent}`);
console.log(` Duration: ${duration} minutes`);
console.log(` Status: ${session.status}`);
console.log(` Verification: ${session.verify ? 'βœ…' : '❌'}`);
+ console.log(` Auto-Verify: ${session.autoVerify ? 'βœ…' : '❌'}`);
console.log(` Testing: ${session.test ? 'βœ…' : '❌'}`);
if (session.verificationScores && session.verificationScores.length > 0) {
- const avgScore = session.verificationScores.reduce((a, b) => a + b, 0) / session.verificationScores.length;
- console.log(` Avg Verification: ${avgScore.toFixed(2)}`);
+ const scores = session.verificationScores.map(s => s.score || s);
+ const avg = scores.reduce((a, b) => a + b, 0) / scores.length;
+ console.log(` Avg Verification: ${avg.toFixed(2)}`);
+ console.log(` Total Checks: ${scores.length}`);
}
}