← Writing

ChatGPT + npm + goal = innovation mining

npm is the default package manager for the JavaScript runtime environment Node.js

The advent of powerful generative AI tools, like ChatGPT, has opened up an exciting new frontier in software innovation. With an on-tap wealth of reasoning power, ChatGPT can propose complex integrated solutions to software problems.

By automating research across vast problem spaces, developers can explore uncharted territories and uncover new, innovative solutions with unprecedented ease. In this article, we’ll delve into the process of creating an automated pipeline that leverages ChatGPT’s immense capabilities.

We’ll generate web tools by combining random npm libraries for specific goals, transforming the way we approach software development and research.

Step 1: Ideate and define a research goal

Begin by brainstorming innovative goals that can drive software development. You can use generative AI tools like ChatGPT to help spark creativity by providing suggestions based on industry trends, user needs, or technological advancements.

The idea here is that you can automate searching over many different combinations of libraries while re-using this goal, so identifying and refining a specific objective that you want to achieve with the web tool you’re creating is valuable. This well-defined goal will guide the ChatGPT model in generating relevant and practical combinations of npm libraries.

Step 2: Prepare a Dataset of npm Libraries

Compile a comprehensive list of npm libraries, including their descriptions, features, and functionalities. This dataset will serve as the knowledge base for ChatGPT to identify suitable library combinations.

Without this step, the model will be prone to using libraries and versions that don’t exist.

Step 3: Use ChatGPT to create a new web tool

Create a novel web tool called 'Meme Mashup Generator' using 3 random libraries from npm. Use common module syntax. The output format is a shell file to run actions to create the tool project. This includes adding relevant folders, initializing node, installing dependencies, adding files, and then creating a build, and serving it locally.

Breakdown of this prompt

  1. Clear and specific goal: The prompt defines a specific objective, which is to create a ‘Meme Mashup Generator’ web tool following viral trends.
  2. Technology focus: It mentions the usage of npm libraries and specifies using common module syntax.
  3. Output format: The desired output format is explicitly stated as a shell file containing the necessary actions to create the tool project.

Limitations of using ChatGPT to generate shell scripts for web project creation

While using ChatGPT to create shell scripts for project automation can streamline the development process, there are some limitations to be aware of:

  1. The trade-off between output quality and automation: Wrapping the prompt in a generated shell script to create the project may reduce the overall quality of the output. However, it increases the level of automation in generating the entire project. To mitigate potential issues, include specific instructions in your prompt to ensure defaults are enabled using the -y flag or | yes where appropriate to avoid waiting on input. Example: “Generate a shell script to create the project, ensuring any shell command has defaults enabled using -y flag or | yes where appropriate to avoid waiting on input.”
  2. Incomplete or improperly formatted scripts: ChatGPT-generated shell scripts might not always run to completion due to issues with escape sequences or poor formatting. To address this limitation, thoroughly review the generated scripts and manually correct any issues before executing them.
  3. Configuration issues in the output project: The output project may not reliably run without intervention to resolve configuration problems. This could be due to inconsistencies in library versions, incompatibilities, or improper settings. To improve the chances of generating a runnable project, include specific requirements or preferences in your prompt, and be prepared to make necessary adjustments to the generated output.
  4. It is more stable to provide a very limited structure for these tools to be built into. Since this is a very challenging problem to automate reducing the complexity with templates in the prompt improves success. I tried adding indications of the expected project structure, package.json format, exact versions of packages, and the build process into the prompt to support more reliable output.

Step 4 (UNSTABLE): Integrating ChatGPT-Generated Web Projects into a CI/CD Pipeline

Integrating GitHub Actions + npm

Once you’ve refined a prompt that reliably creates entire web projects from scratch without manual input, the next step is to integrate this process into a Continuous Integration and Continuous Deployment (CI/CD) pipeline, such as GitHub Actions. This allows for a seamless workflow from generating the project with ChatGPT to building and deploying it on a web server. Here’s a high-level overview of the process:

  1. Create a GitHub Actions workflow: Set up a GitHub Actions workflow in your repository that triggers the desired pipeline, such as on push to the main branch or when a new pull request is created.
  2. Call the OpenAI API: Within the workflow, add a step that calls the OpenAI API to run the refined prompt using ChatGPT. You can use the OpenAI GitHub Actions or call the API using an HTTP client like curl or a custom script.
  3. Generate the project: The ChatGPT output should include the shell script to create the web project. Save this script to a temporary location within the GitHub Actions runner workspace.
  4. Execute the shell script: Run the shell script within the GitHub Actions environment to create the project, including all necessary files, folders, and configurations.
  5. Commit the generated project: After the project is generated, commit the new files and folders to the repository using standard Git commands within the GitHub Actions workflow.
  6. Build the project: In the workflow, add a step to build the generated project using the appropriate build tools and commands based on the project type and technology stack.
  7. Deploy the build: Finally, deploy the built project to a web server or hosting platform of your choice. This can be achieved using various deployment strategies and tools, such as GitHub Pages, Netlify, or AWS S3.

By integrating the ChatGPT-generated web projects into a CI/CD pipeline, you can automate the entire process from idea generation to deployment, significantly streamlining software development and fostering rapid innovation.