@@ -221,14 +221,35 @@ private static String getCliPath(Path repoRoot) throws IOException {
221221 return envPath ;
222222 }
223223
224+ // Try test harness platform-specific binary (preferred as it works directly)
225+ String os = System .getProperty ("os.name" ).toLowerCase ();
226+ String arch = System .getProperty ("os.arch" ).toLowerCase ();
227+ String platform = os .contains ("mac" ) ? "darwin" : os .contains ("win" ) ? "win32" : "linux" ;
228+ String cpuArch = arch .contains ("aarch64" ) || arch .contains ("arm64" ) ? "arm64" : "x64" ;
229+ Path platformBinary = repoRoot
230+ .resolve ("test/harness/node_modules/@github/copilot-" + platform + "-" + cpuArch + "/copilot" );
231+ if (os .contains ("win" )) {
232+ platformBinary = repoRoot
233+ .resolve ("test/harness/node_modules/@github/copilot-" + platform + "-" + cpuArch + "/copilot.exe" );
234+ }
235+ if (Files .exists (platformBinary )) {
236+ return platformBinary .toString ();
237+ }
238+
239+ // Try test harness npm-loader.js
240+ Path harnessCliPath = repoRoot .resolve ("test/harness/node_modules/@github/copilot/npm-loader.js" );
241+ if (Files .exists (harnessCliPath )) {
242+ return harnessCliPath .toString ();
243+ }
244+
224245 // Try nodejs installation
225246 Path cliPath = repoRoot .resolve ("nodejs/node_modules/@github/copilot/index.js" );
226247 if (Files .exists (cliPath )) {
227248 return cliPath .toString ();
228249 }
229250
230251 throw new IOException ("CLI not found. Either install 'copilot' globally, set COPILOT_CLI_PATH, "
231- + "or run 'npm install' in the nodejs directory." );
252+ + "or run 'npm install' in the nodejs directory or test/harness directory ." );
232253 }
233254
234255 private static String findCopilotInPath () {
0 commit comments