RepoSnap — a simple way to build efficient repo-based apps

date
Sep 30, 2024
slug
simple-way-to-build-efficient-repo-based-apps
status
Published
tags
Coding
Repository
Bash
AI
summary
RepoSnap is a Chrome extension designed to streamline the process of making GitHub repository-based applications work (on Windows) by generating bash scripts directly from the README files of that GitHub repository.
type
Post

What and why? — Overview and Purpose

RepoSnap is a Chrome extension designed to streamline the process of making GitHub repository-based applications work (on Windows) by generating bash scripts directly from the README files of that GitHub epository. It is especially useful for developers or enthusiasts (like you) who often need to execute commands or scripts belonging to a repository (like described in the README of GitHub Repositories) but prefer to automate the process of building an app from source or running a script with the correct command line arguments and want to avoid running into dependency problems which may need searching the web for hours.
The primary purpose of this extension is to save time and as mentioned reduce the potential for errors (e.g. dependency issues) by automating the creation of bash scripts that can be executed directly on your system. The script generation is based on the gpt-3.5-turbo model by OpenAI which is a well-trained and fast option for generating comprehensive bash scripts in terms of order and purpose. Instead of manually chosen the right commands for your purpose by browsing the README file, you can generate a ready-to-use script with a single click while browsing the GitHub repository.
notion image
Image 1: Example image of the extension after generating a script based on the PaLM-rlhf-pytorch repository

Solution explained

As mentioned, the extension’s script generation is based on the gpt-3.5-turbo model which receives a prompt with the help of the OpenAI API. The prompt contains a custom request message (instructions) followed by the README file’s content, which is fetch from the active GitHub repository chrome tab.The solution locally is based on two main components. The chrome extension (1) and a local (Node.js based) server (2) which establishes he connection between the extension and the OpenAI server. The chrome extension’s purpose is to read the ctive tabs content (the README) and to display the output (bash script).

Working mechanism described in steps:

1. README Content fetching:
The reads in the repository’s README file when you visit (active tab) a GitHub repository page.
2. Script Generation:
Using the OpenAI API, the extension sends the prompt containing the fetched README, the model generates a bash script and sends back.
3. Displaying Script:
The generated script is displayed in the extension’s popup window, where you can review and copy the generated script.
4. Executing Script:
Users can then paste the copied script into their terminal and execute it to perform the setup/build/scripting described in the README.

Installation

Prerequisites

  • Google Chrome: required to run the extension.
  • OpenAI API Key: required for generate the bash script using OpenAI’s model.
  • NodeJS: required for the local server

Steps to Install

  1. Clone the Repository: Download the extension’s code to your local machine (using git or manually):
2. Set Up the API Key: Create a .env file in the `/openai-backend` directory and add your OpenAI API key:
3. Start the Node.js server: Navigate to `/openai-backend` directory and start the server (server.js):
4. Load the Extension in Chrome:
· Open Google Chrome
· Go to `chrome://extensions/` in your Chrome browser.
· Enable “Developer mode”.
· Click “Load unpacked” and select the folder where you downloaded the extension (`/chrome-extension`)
5. Use the Extension:
· Visit any GitHub repository containing a README with installation/build/scripting instructions.
· Click the RepoSnap icon in the Chrome toolbar.
· Click “Generate Script” to produce a bash script based on the repository’s README content.
· Click “Copy Script” to copy a bash script to your clipboard.

My Conclusion

RepoSnap is a simple yet powerful tool that boosts workflow by automating the creation of bash scripts from GitHub READMEs. It is particularly beneficial for developers who regularly work with open-source projects and need a quick way to get up and running with new tools or environments. By building this projects I learned how APIs work and how to efficiently implement and integrate a node.js server with a chrome extension. In the future I want to improve the prompt message to enhance the quality of generated bash scripts.

© mesh. 2023 - 2025