GenAIScript use stylized JavaScript with minimal syntax.
They are stored as files (genaisrc/*.genai.mjs or genaisrc/*.genai.mts) in your project.
The execution of a genaiscript creates the prompt that will be sent to the LLM.
Use the > GenAiScript: Create new script... command in the command palette
(Ctrl+Shift+P on Windows/Linux, ⇧⌘P on Mac)
to create a new script.
Run the cliscript create command with the name of the script you want to create.
The resulting file will be placed in the genaisrc folder in your project.
…
Directorygenaisrcscripts are created here by default
genaiscript.d.ts(TypeScript type definitions)
jsconfig.json(TypeScript compiler configuration)
proofreader.genai.mjs
…
…
the Prompt
The execution of the GenAIScript generates a prompt (and more)
that gets sent to the LLM model.
The $``...`` template string function formats and write the string to the prompt;
which gets sent to the LLM.
👤 user🤖 assistant
the Context
GenAIScript exposes the context through the env variable. The context is implicitly defined by the location you start executing the script.
you can right click on a folder and the env.files will contain all the files nested in that folder.
you can right click on or in a file and the env.files will contain only that file.
you can run the script using the command line interface and specify content of env.files in the CLI arguments.
👤 user
the Task
The $ function is used to build the prompt text, it renders and writes the text to the prompt
($ is a template literal).
👤 user🤖 assistant
the Metadata
You can add a call to the script function to provides metadata about the script
and the model. The metadata is used to display the script in the UI and configure the LLM model.
👤 user🤖 assistant
The title, description, and group properties are used to display the script in the UI
and can be helpful when the user is searching for a script.
Next steps
Follow the Prompt As Code guide to dive deeper in programmatically generating prompts