Skip to content

Overview

The GenAIScript CLI genaiscript runs GenAIScript scripts outside of Visual Studio and in your automation.

Terminal window
npx --yes genaiscript ...

where --yes skips the confirmation prompt to install the package.

Prerequisites

The CLI is a Node.JS package hosted on npm.

Installation

  • Install locally as a devDependency in your project.
Terminal window
npm install -D genaiscript
  • Install it globally.
Terminal window
npm install -g genaiscript
  • Check that your node version is at least 20._ and npm 10._ by running this command.
Terminal window
node -v
npx -v
v20.11.1
10.5.0

No Installation (npx)

npx is installed with Node.JS.

Using npx, you can run the cli without any prior installation steps. npx will install the tool on demand. npx also takes care of tricky operating system issues where the tool is not found in the path.

Terminal window
npx genaiscript ...
  • Add --yes to skip the confirmation prompt, which is useful in a CI scenario.
Terminal window
npx --yes genaiscript ...
  • Specify the version range to avoid unexpected behavior with cached installations of the CLI using npx.
Terminal window
npx --yes genaiscript@^1.16.0 ...

Configuration

The CLI will load the secrets from the environment variables or a ./.env file.

You can override the default .env file name by adding the --env myother.env file.

Create a new script

Creates a new script file in the genaisrc folder.

Terminal window
npx genaiscript scripts create <name>

Compile scripts

Runs the TypeScript compiler to find errors in the scripts.

Terminal window
npx genaiscript scripts compile

Run a script

Run a script on file and streams the LLM output to stdout. Run from the workspace root.

Terminal window
npx genaiscript run <script> [files...]

where <script> is the id or file path of the tool to run, and [files...] is the name of the spec file to run it on.

Listing model configuration

Run the script model command to list the available scripts and their model configuration. This can be useful to diagnose configuration issues in CI/CD environments.

Terminal window
npx genaiscript scripts model [script]

where [script] can be a script id or a file path.

Topics