Skip to content

Instantly share code, notes, and snippets.

@ibuildthecloud
Created May 22, 2024 00:43
Show Gist options
  • Save ibuildthecloud/7bef29ddb5da29d3816fdb4ee3d55e7d to your computer and use it in GitHub Desktop.
Save ibuildthecloud/7bef29ddb5da29d3816fdb4ee3d55e7d to your computer and use it in GitHub Desktop.
GPTScript to mimic Windows DevHome "Quickstart Playground" features
description: Generates a dev env from a prompt
tools: lang, prog, language-deps, devcontainer, launch
arg: prompt: The description of the program you would like to create
Do the following sequentially, not in parallel
1. Call @lang with ${prompt} to determine what programming language would be best suited for this task
1. Call @prog with ${prompt} and the determined language
1. Call @language-deps
1. Call @devcontainer
1. Call @launch
---
name: launch
context: workspace
Do the following sequentially
1. List all the files in the current workspace, recursively
2. Read each file in the workspace to understand it's contents.
3. Generate an appropriate .vscode/launch.json file
4. Write the resulting files to disk in the workspace
---
name: devcontainer
context: workspace
Do the following sequentially
1. List all the files in the current workspace, recursively
2. Read each file in the workspace to understand it's contents.
3. Generate an appropriate .devcontainer/devcontainer.json file
3. Generate an appropriate .devcontainer/Dockerfile file
4. Write the resulting files to disk in the workspace
---
name: language-deps
context: workspace
Do the following sequentially
1. List all the files in the current workspace, recursively
2. Read each file in the workspace to understand it's contents.
3. Generate any appropriate standard build files and package dependencies files such that a user can build and run this application.
4. Write the resulting files to disk in the workspace
---
name: prog
context: workspace
args: language: The language to use
args: prompt: The description of the program you would like to create
Write a program to disk using the language ${lang} that does "${prompt}"
---
name: lang
arg: prompt: The description of the program you would like to create
Analyize ${prompt} and pick the best programming lanuage for that prompt. If the prompt
specificies a specific language or a framework from a language use that.
Print the determined programming language
---
name: workspace
export: sys.read?, sys.write, sys.ls
#!/bin/bash
echo "You have the following workspace available to you $GPTSCRIPT_WORKSPACE_DIR"
echo "Create all new files in $GPTSCRIPT_WORKSPACE_DIR"
@ibuildthecloud
Copy link
Author

ibuildthecloud commented May 22, 2024

I wrote this in 5 minutes to mimic https://www.youtube.com/watch?v=Y6dLxRmDESQ cause I thought it was cool. YMMV.

Run this with

gptscript --workspace ./workspace https://gist.githubusercontent.com/ibuildthecloud/7bef29ddb5da29d3816fdb4ee3d55e7d/raw/c3c4fffcb6c03c580b5778008a683292544bec2a/quickstart-playground.gpt \
   --prompt='Create a project to visualize the Mandlebrot set and then another 3D math function'

And then you should get

$ find ./workspace
./workspace/
./workspace/mandelbrot.py
./workspace/README.md
./workspace/.vscode
./workspace/.vscode/launch.json
./workspace/.devcontainer
./workspace/.devcontainer/Dockerfile
./workspace/.devcontainer/devcontainer.json
./workspace/3d_math_function.py
./workspace/requirements.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment