DEV Community

WH yang
WH yang

Posted on

New --remote feature in the Repopal

Inspired by Repomix, I added a new option to my Repopal project. Both projects aim to extract source code in a way that helps language models understand it.

Repomix has a --remote option in its command line interface (CLI). This allows users to provide a URL, and Repomix will clone and extract the code from that repository. I created my own version of the --remote option.

Repomix uses the child_process module to run the Git CLI tool, like this:

import { execFile } from 'node:child_process';
const execFileAsync = promisify(execFile);
await deps.execFileAsync('git', ['-C', directory, 'checkout', 'FETCH_HEAD']);
Enter fullscreen mode Exit fullscreen mode

In my project, I used simple-git instead. Here’s how I implemented the clone function:

import { simpleGit } from "simple-git";
export async function cloneRemoteRepo(remoteUrl: string): Promise<string> {
  const tempDir = path.join('temp');
  const git = simpleGit();
  await git.clone(remoteUrl, tempDir);
  return tempDir;
}
Enter fullscreen mode Exit fullscreen mode

After completing my version of the --remote option, I noticed that Repomix also has a --remote-branch option. This option lets users specify which branch to extract, which is important for getting code from experimental feature branches. I also have to document the new options on the readme file later.

Top comments (0)