diff --git a/docs/commands/agents.md b/docs/commands/agents.md deleted file mode 100644 index 1f6cafdee62..00000000000 --- a/docs/commands/agents.md +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: Netlify CLI agents command -sidebar: - label: agents -description: Manage Netlify AI agent tasks for automated development workflows ---- - -# `agents` - - -Manage Netlify AI agent tasks -The `agents` command will help you run AI agents on your Netlify sites to automate development tasks - -Note: Agent tasks execute remotely on Netlify infrastructure, not locally. - -**Usage** - -```bash -netlify agents -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`agents:create`](/commands/agents#agentscreate) | Create and run a new agent task on your site | -| [`agents:list`](/commands/agents#agentslist) | List agent tasks for the current site | -| [`agents:show`](/commands/agents#agentsshow) | Show details of a specific agent task | -| [`agents:stop`](/commands/agents#agentsstop) | Stop a running agent task | - - -**Examples** - -```bash -netlify agents:create --prompt "Add a contact form" -netlify agents:list --status running -netlify agents:show 60c7c3b3e7b4a0001f5e4b3a -``` - ---- -## `agents:create` - -Create and run a new agent task on your site - -**Usage** - -```bash -netlify agents:create -``` - -**Arguments** - -- prompt - the prompt for the agent to execute - -**Flags** - -- `agent` (*string*) - agent type (claude, codex, gemini) -- `branch` (*string*) - git branch to work on -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - output result as JSON -- `model` (*string*) - model to use for the agent -- `project` (*string*) - project ID or name (if not in a linked directory) -- `prompt` (*string*) - agent prompt -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify agents:create -netlify agents:create "Fix the login bug" -netlify agents:create --prompt "Add dark mode" --agent claude -netlify agents:create -p "Update README" -a codex -b feature-branch -netlify agents:create "Add tests" --project my-site-name -``` - ---- -## `agents:list` - -List agent tasks for the current site - -**Usage** - -```bash -netlify agents:list -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - output result as JSON -- `project` (*string*) - project ID or name (if not in a linked directory) -- `status` (*string*) - filter by status (new, running, done, error, cancelled) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify agents:list -netlify agents:list --status running -netlify agents:list --json -``` - ---- -## `agents:show` - -Show details of a specific agent task - -**Usage** - -```bash -netlify agents:show -``` - -**Arguments** - -- id - agent task ID to show - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - output result as JSON -- `project` (*string*) - project ID or name (if not in a linked directory) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify agents:show 60c7c3b3e7b4a0001f5e4b3a -netlify agents:show 60c7c3b3e7b4a0001f5e4b3a --json -``` - ---- -## `agents:stop` - -Stop a running agent task - -**Usage** - -```bash -netlify agents:stop -``` - -**Arguments** - -- id - agent task ID to stop - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - output result as JSON -- `project` (*string*) - project ID or name (if not in a linked directory) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify agents:stop 60c7c3b3e7b4a0001f5e4b3a -``` - ---- - - diff --git a/docs/commands/api.md b/docs/commands/api.md deleted file mode 100644 index a5561037f92..00000000000 --- a/docs/commands/api.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: Netlify CLI api command -sidebar: - label: api ---- - -# `api` - -The `api` command will let you call any [Netlify open API methods](https://open-api.netlify.com/) - - -Run any Netlify API method -For more information on available methods check out https://open-api.netlify.com/ or run 'netlify api --list' - -**Usage** - -```bash -netlify api -``` - -**Arguments** - -- apiMethod - Open API method to run - -**Flags** - -- `data` (*string*) - Data to use -- `list` (*boolean*) - List out available API methods -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify api --list -netlify api getSite --data '{ "site_id": "123456" }' -``` - - - diff --git a/docs/commands/blobs.md b/docs/commands/blobs.md deleted file mode 100644 index a0a6fb52b4f..00000000000 --- a/docs/commands/blobs.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -title: Netlify CLI blobs command -sidebar: - label: blobs -description: Manage objects in Netlify Blobs ---- - -# `blobs` - - -Manage objects in Netlify Blobs - -**Usage** - -```bash -netlify blobs -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`blobs:delete`](/commands/blobs#blobsdelete) | Deletes an object with a given key, if it exists, from a Netlify Blobs store | -| [`blobs:get`](/commands/blobs#blobsget) | Reads an object with a given key from a Netlify Blobs store and, if it exists, prints the content to the terminal or saves it to a file | -| [`blobs:list`](/commands/blobs#blobslist) | Lists objects in a Netlify Blobs store | -| [`blobs:set`](/commands/blobs#blobsset) | Writes to a Netlify Blobs store an object with the data provided in the command or the contents of a file defined by the 'input' parameter | - - -**Examples** - -```bash -netlify blobs:get my-store my-key -netlify blobs:set my-store my-key This will go in a blob -netlify blobs:set my-store my-key --input ./some-file.txt -netlify blobs:delete my-store my-key -netlify blobs:list my-store -netlify blobs:list my-store --json -``` - ---- -## `blobs:delete` - -Deletes an object with a given key, if it exists, from a Netlify Blobs store - -**Usage** - -```bash -netlify blobs:delete -``` - -**Arguments** - -- store - Name of the store -- key - Object key - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Bypasses prompts & Force the command to run. -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `blobs:get` - -Reads an object with a given key from a Netlify Blobs store and, if it exists, prints the content to the terminal or saves it to a file - -**Usage** - -```bash -netlify blobs:get -``` - -**Arguments** - -- store - Name of the store -- key - Object key - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `output` (*string*) - Defines the filesystem path where the blob data should be persisted -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `blobs:list` - -Lists objects in a Netlify Blobs store - -**Usage** - -```bash -netlify blobs:list -``` - -**Arguments** - -- store - Name of the store - -**Flags** - -- `directories` (*boolean*) - Indicates that keys with the '/' character should be treated as directories, returning a list of sub-directories at a given level rather than all the keys inside them -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output list contents as JSON -- `prefix` (*string*) - A string for filtering down the entries; when specified, only the entries whose key starts with that prefix are returned -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `blobs:set` - -Writes to a Netlify Blobs store an object with the data provided in the command or the contents of a file defined by the 'input' parameter - -**Usage** - -```bash -netlify blobs:set -``` - -**Arguments** - -- store - Name of the store -- key - Object key -- value - Object value - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Bypasses prompts & Force the command to run. -- `input` (*string*) - Defines the filesystem path where the blob data should be read from -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- - - diff --git a/docs/commands/build.md b/docs/commands/build.md deleted file mode 100644 index 2b345292b36..00000000000 --- a/docs/commands/build.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: Netlify CLI build command -sidebar: - label: build ---- - -# `build` - - -Build on your local machine - -**Usage** - -```bash -netlify build -``` - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables read during the build (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: value of CONTEXT or ”production”) -- `dry` (*boolean*) - Dry run: show instructions without running them -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `offline` (*boolean*) - Disables any features that require network access - -**Examples** - -```bash -netlify build -netlify build --context deploy-preview # Build with env var values from deploy-preview context -netlify build --context branch:feat/make-it-pop # Build with env var values from the feat/make-it-pop branch context or branch-deploy context -``` - - - diff --git a/docs/commands/claim.md b/docs/commands/claim.md deleted file mode 100644 index 74a43631e45..00000000000 --- a/docs/commands/claim.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: Netlify CLI claim command -sidebar: - label: claim ---- - -# `claim` - - -Claim an anonymously deployed site and link it to your account - -**Usage** - -```bash -netlify claim -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `site` (*string*) - The site ID of the anonymous deploy to claim (required) -- `token` (*string*) - The drop token provided when the site was deployed (required) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify claim --site abc123 --token drop-jwt-token -``` - - - diff --git a/docs/commands/clone.md b/docs/commands/clone.md deleted file mode 100644 index d67d38b62b5..00000000000 --- a/docs/commands/clone.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: Netlify CLI clone command -sidebar: - label: clone -description: Clone a remote repo and link it to an existing project on Netlify ---- - -# `clone` - - -Clone a remote repository and link it to an existing project on Netlify -Use this command when the existing Netlify project is already configured to deploy from the existing repo. - -If you specify a target directory, the repo will be cloned into that directory. By default, a directory will be created with the name of the repo. - -To specify a project, use --id or --name. By default, the Netlify project to link will be automatically detected if exactly one project found is found with a matching git URL. If we cannot find such a project, you will be interactively prompted to select one. - -**Usage** - -```bash -netlify clone -``` - -**Arguments** - -- repo - URL of the repository to clone or Github `owner/repo` (required) -- targetDir - directory in which to clone the repository - will be created if it does not exist - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `id` (*string*) - ID of existing Netlify project to link to -- `name` (*string*) - Name of existing Netlify project to link to -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify clone vibecoder/next-unicorn -netlify clone https://github.com/vibecoder/next-unicorn.git -netlify clone git@github.com:vibecoder/next-unicorn.git -netlify clone vibecoder/next-unicorn ./next-unicorn-shh-secret -netlify clone --id 123-123-123-123 vibecoder/next-unicorn -netlify clone --name my-project-name vibecoder/next-unicorn -``` - - - diff --git a/docs/commands/completion.md b/docs/commands/completion.md deleted file mode 100644 index 71e9ee5d967..00000000000 --- a/docs/commands/completion.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: Netlify CLI completion command -sidebar: - label: completion -description: Shell completion script for netlify CLI ---- - -# `completion` - - -Generate shell completion script -Run this command to see instructions for your shell. - -**Usage** - -```bash -netlify completion -``` - -**Flags** - -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`completion:install`](/commands/completion#completioninstall) | Generates completion script for your preferred shell | - - -**Examples** - -```bash -netlify completion:install -``` - ---- -## `completion:install` - -Generates completion script for your preferred shell - -**Usage** - -```bash -netlify completion:install -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- - - diff --git a/docs/commands/create.md b/docs/commands/create.md deleted file mode 100644 index e6f22f2596c..00000000000 --- a/docs/commands/create.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: Netlify CLI create command -sidebar: - label: create -description: Create a new Netlify project using an AI agent ---- - -# `create` - - -Create a new Netlify project using an AI agent - -**Usage** - -```bash -netlify create -``` - -**Arguments** - -- prompt - description of the site to create - -**Flags** - -- `account-slug` (*string*) - account slug to create the project under -- `agent` (*string*) - agent type (claude, codex, gemini) -- `dir` (*string*) - directory to create the project in (defaults to current directory) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `git` (*string*) - create a git repository and push source code (e.g. github) -- `json` (*boolean*) - output result as JSON -- `model` (*string*) - model to use for the agent -- `name` (*string*) - project name (subdomain) -- `no-download` (*boolean*) - skip downloading source code after the agent run completes -- `no-wait` (*boolean*) - return immediately after starting the agent run without polling for completion -- `prompt` (*string*) - description of the site to create -- `repo-owner` (*string*) - GitHub org or user to create the repo under -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify create "a portfolio site" -netlify create --prompt "a blog with dark mode" --agent claude -netlify create "landing page for a coffee shop" --account-slug my-team -netlify create "an e-commerce store" --name my-store -netlify create "an e-commerce store" --git github -netlify create "an e-commerce store" --no-wait -``` - - - diff --git a/docs/commands/database.md b/docs/commands/database.md deleted file mode 100644 index b3de82e4d64..00000000000 --- a/docs/commands/database.md +++ /dev/null @@ -1,272 +0,0 @@ ---- -title: Netlify CLI database command -description: Provision a production ready Postgres database with a single command -sidebar: - label: database ---- - -# `database` - - - -Provision a production ready Postgres database with a single command - -**Usage** - -```bash -netlify database -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`database status`](/commands/database#database-status) | Check the status of the database, including applied and pending migrations | -| [`database init`](/commands/database#database-init) | Interactive setup: install the package, scaffold a starter migration, and verify the database | -| [`database connect`](/commands/database#database-connect) | Connect to the database | -| [`database reset`](/commands/database#database-reset) | Reset the local development database, removing all data and tables | -| [`database migrations`](/commands/database#database-migrations) | Manage database migrations | - - -**Examples** - -```bash -netlify database status -netlify database migrations apply -netlify database migrations pull -netlify database migrations new -netlify database reset -``` - ---- -## `database status` - -Check the status of the database, including applied and pending migrations - -**Usage** - -```bash -netlify database status -``` - -**Flags** - -- `branch` (*string*) - Netlify branch name to query; defaults to the local development database -- `json` (*boolean*) - Output result as JSON -- `show-credentials` (*boolean*) - Include the full connection string (including username and password) in the output -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify database status -netlify database status --show-credentials -netlify database status --json -netlify database status --branch my-feature-branch -``` - ---- -## `database init` - -Interactive setup: install the package, scaffold a starter migration, and verify the database - -**Usage** - -```bash -netlify database init -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `yes` (*boolean*) - Non-interactive mode. Accepts the defaults for every prompt. -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify database init -netlify database init --yes -``` - ---- -## `database connect` - -Connect to the database - -**Usage** - -```bash -netlify database connect -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output query results as JSON. When used without --query, prints the connection details as JSON instead. -- `query` (*string*) - Execute a single query and exit -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify database connect -netlify database connect --query "SELECT * FROM users" -netlify database connect --json --query "SELECT * FROM users" -netlify database connect --json -``` - ---- -## `database reset` - -Reset the local development database, removing all data and tables - -**Usage** - -```bash -netlify database reset -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output result as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `database migrations` - -Manage database migrations - -**Usage** - -```bash -netlify database migrations -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`database migrations apply`](/commands/database#database-migrations-apply) | Apply database migrations to the local development database | -| [`database migrations new`](/commands/database#database-migrations-new) | Create a new migration | -| [`database migrations pull`](/commands/database#database-migrations-pull) | Pull migrations and overwrite local migration files | -| [`database migrations reset`](/commands/database#database-migrations-reset) | Delete local migration files that have not been applied yet | - - ---- -## `database migrations apply` - -Apply database migrations to the local development database - -**Usage** - -```bash -netlify database migrations apply -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output result as JSON -- `to` (*string*) - Target migration name or prefix to apply up to (applies all if omitted) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `database migrations new` - -Create a new migration - -**Usage** - -```bash -netlify database migrations new -``` - -**Flags** - -- `description` (*string*) - Purpose of the migration (used to generate the file name) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output result as JSON -- `scheme` (*timestamp | sequential*) - Numbering scheme for migration prefixes -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify database migrations new -netlify database migrations new --description "add users table" --scheme sequential -``` - ---- -## `database migrations pull` - -Pull migrations and overwrite local migration files - -**Usage** - -```bash -netlify database migrations pull -``` - -**Flags** - -- `branch` (*string*) - Pull migrations for a specific branch (defaults to 'production'; pass --branch with no value to use local git branch) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Skip confirmation prompt -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `json` (*boolean*) - Output result as JSON - -**Examples** - -```bash -netlify database migrations pull -netlify database migrations pull --branch staging -netlify database migrations pull --branch -netlify database migrations pull --force -``` - ---- -## `database migrations reset` - -Delete local migration files that have not been applied yet - -**Usage** - -```bash -netlify database migrations reset -``` - -**Flags** - -- `branch` (*string*) - Target a remote preview branch instead of the local development database -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output result as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify database migrations reset -netlify database migrations reset --branch my-feature-branch -``` - ---- - - diff --git a/docs/commands/deploy.md b/docs/commands/deploy.md deleted file mode 100644 index 7021bd110e6..00000000000 --- a/docs/commands/deploy.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: Netlify CLI deploy command -sidebar: - label: deploy ---- - -# `deploy` - - -Deploy your project to Netlify - -Builds and deploys your project to Netlify. Creates a draft deploy by default. -Use --prod to deploy directly to your live site. - -The deploy command will: -- Build your project (unless --no-build is specified) -- Upload static files, functions, and edge functions -- Process redirects and headers from netlify.toml or _redirects/_headers files -- Provide deploy and function logs URLs - -For detailed configuration options, see the Netlify documentation. - -**Usage** - -```bash -netlify deploy -``` - -**Flags** - -- `alias` (*string*) - Specifies the alias for deployment, the string at the beginning of the deploy subdomain. Useful for creating predictable deployment URLs. Avoid setting an alias string to the same value as a deployed branch. `alias` doesn’t create a branch deploy and can’t be used in conjunction with the branch subdomain feature. Maximum 37 characters. -- `allow-anonymous` (*boolean*) - If not logged in, deploy anonymously and create a claimable site instead of requiring authentication -- `context` (*string*) - Specify a deploy context for environment variables read during the build ("production", "deploy-preview", "branch-deploy", "dev") or `branch:your-branch` where `your-branch` is the name of a branch (default: dev) -- `created-via` (*string*) - Specify the source of the deploy (e.g., "cli", "drop") -- `dir` (*string*) - Specify a folder to deploy -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `functions` (*string*) - Specify a functions folder to deploy -- `json` (*boolean*) - Output deployment data as JSON -- `message` (*string*) - A short message to include in the deploy log -- `no-build` (*boolean*) - Do not run build command before deploying. Only use this if you have no need for a build or your project has already been built. -- `open` (*boolean*) - Open project after deploy -- `prod-if-unlocked` (*boolean*) - Deploy to production if unlocked, create a draft otherwise -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `prod` (*boolean*) - Deploy to production -- `site` (*string*) - A project name or ID to deploy to -- `site-name` (*string*) - Name for a new site. Implies --create-site if the site does not already exist. -- `skip-functions-cache` (*boolean*) - Ignore any functions created as part of a previous `build` or `deploy` commands, forcing them to be bundled again as part of the deployment -- `team` (*string*) - Specify team slug when creating a site. Only works with --create-site or --site-name flag. -- `timeout` (*string*) - Timeout to wait for deployment to finish -- `trigger` (*boolean*) - Trigger a new build of your project on Netlify without uploading local files - -**Examples** - -```bash -netlify deploy -netlify deploy --site my-first-project -netlify deploy --no-build # Deploy without running a build first -netlify deploy --prod -netlify deploy --prod --open -netlify deploy --prod-if-unlocked -netlify deploy --message "A message with an $ENV_VAR" -netlify deploy --auth $NETLIFY_AUTH_TOKEN -netlify deploy --trigger -netlify deploy --context deploy-preview -netlify deploy --site-name my-new-site --team my-team # Create site and deploy -netlify deploy --allow-anonymous --dir ./public --no-build # Deploy without auth -``` - - - diff --git a/docs/commands/dev.md b/docs/commands/dev.md deleted file mode 100644 index cba068156ce..00000000000 --- a/docs/commands/dev.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Netlify CLI dev command -sidebar: - label: dev -description: Run netlify dev locally ---- - -# `dev` - - -Local dev server -The dev command will run a local dev server with Netlify's proxy and redirect rules - -**Usage** - -```bash -netlify dev -``` - -**Flags** - -- `command` (*string*) - command to run -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: dev) -- `country` (*string*) - Two-letter country code (https://ntl.fyi/country-codes) to use as mock geolocation (enables --geo=mock automatically) -- `dir` (*string*) - dir with static files -- `edge-inspect` (*string*) - enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format -- `edge-inspect-brk` (*string*) - enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `framework` (*string*) - framework to use. Defaults to #auto which automatically detects a framework -- `functions` (*string*) - specify a functions folder to serve -- `functions-port` (*string*) - port of functions server -- `geo` (*cache | mock | update*) - force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location -- `live` (*string*) - start a public live session; optionally, supply a subdomain to generate a custom URL -- `no-open` (*boolean*) - disables the automatic opening of a browser window -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `offline` (*boolean*) - Disables any features that require network access -- `port` (*string*) - port of netlify dev -- `skip-gitignore` (*boolean*) - skip adding .netlify to .gitignore file -- `target-port` (*string*) - port of target app server - -| Subcommand | description | -|:--------------------------- |:-----| -| [`dev:exec`](/commands/dev#devexec) | Runs a command within the netlify dev environment. For example, with environment variables from any installed add-ons | - - -**Examples** - -```bash -netlify dev -netlify dev -d public -netlify dev -c "hugo server -w" --target-port 1313 -netlify dev --context production # Use env var values from production context -netlify dev --context deploy-preview # Use env var values from deploy-preview context -netlify dev --context branch:feat/make-it-pop # Use env var values from the feat/make-it-pop branch context or branch-deploy context -netlify dev --edge-inspect -netlify dev --edge-inspect=127.0.0.1:9229 -netlify dev --edge-inspect-brk -netlify dev --edge-inspect-brk=127.0.0.1:9229 -netlify dev --skip-gitignore # skip adding .netlify to .gitignore -BROWSER=none netlify dev # disable browser auto opening -``` - ---- -## `dev:exec` - -Runs a command within the netlify dev environment. For example, with environment variables from any installed add-ons - -**Usage** - -```bash -netlify dev:exec -``` - -**Arguments** - -- ...cmd - the command that should be executed - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: dev) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify dev:exec npm run bootstrap -netlify dev:exec --context deploy-preview npm run bootstrap # Run with env var values from deploy-preview context -netlify dev:exec --context branch:feat/make-it-pop npm run bootstrap # Run with env var values from the feat/make-it-pop branch context or branch-deploy context -``` - ---- - - diff --git a/docs/commands/env.md b/docs/commands/env.md deleted file mode 100644 index 930790b7fbb..00000000000 --- a/docs/commands/env.md +++ /dev/null @@ -1,240 +0,0 @@ ---- -title: Netlify CLI env command -sidebar: - label: env -description: Control environment variables for the current project ---- - -# `env` - - -Control environment variables for the current project - -**Usage** - -```bash -netlify env -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`env:clone`](/commands/env#envclone) | Clone environment variables from one project to another | -| [`env:get`](/commands/env#envget) | Get resolved value of specified environment variable (includes netlify.toml) | -| [`env:import`](/commands/env#envimport) | Import and set environment variables from .env file | -| [`env:list`](/commands/env#envlist) | Lists resolved environment variables for project (includes netlify.toml) | -| [`env:set`](/commands/env#envset) | Set value of environment variable | -| [`env:unset`](/commands/env#envunset) | Unset an environment variable which removes it from the UI | - - -**Examples** - -```bash -netlify env:list -netlify env:get VAR_NAME -netlify env:set VAR_NAME value -netlify env:unset VAR_NAME -netlify env:import fileName -netlify env:clone --to -``` - ---- -## `env:clone` - -Clone environment variables from one project to another - -**Usage** - -```bash -netlify env:clone -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Bypasses prompts & Force the command to run. -- `from` (*string*) - Project ID (From) -- `to` (*string*) - Project ID (To) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify env:clone --to -netlify env:clone --to --from -``` - ---- -## `env:get` - -Get resolved value of specified environment variable (includes netlify.toml) - -**Usage** - -```bash -netlify env:get -``` - -**Arguments** - -- name - Environment variable name - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output environment variables as JSON -- `scope` (*builds | functions | post-processing | runtime | any*) - Specify a scope -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `site` (*string*) - A project name or ID to target - -**Examples** - -```bash -netlify env:get MY_VAR # get value for MY_VAR in dev context -netlify env:get MY_VAR --context production -netlify env:get MY_VAR --context branch:feat/make-it-pop # get value in the feat/make-it-pop branch context or branch-deploy context -netlify env:get MY_VAR --scope functions -``` - ---- -## `env:import` - -Import and set environment variables from .env file - -**Usage** - -```bash -netlify env:import -``` - -**Arguments** - -- fileName - .env file to import - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output environment variables as JSON -- `replace-existing` (*boolean*) - Replace all existing variables instead of merging them with the current ones -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `site` (*string*) - A project name or ID to target - ---- -## `env:list` - -Lists resolved environment variables for project (includes netlify.toml) - -**Usage** - -```bash -netlify env:list -``` - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: all contexts) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output environment variables as JSON -- `plain` (*boolean*) - Output environment variables as plaintext -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `scope` (*builds | functions | post-processing | runtime | any*) - Specify a scope -- `site` (*string*) - A project name or ID to target - -**Examples** - -```bash -netlify env:list # list variables with values in the dev context and with any scope -netlify env:list --context production -netlify env:list --context branch:feat/make-it-pop # list variables with values in the feat/make-it-pop branch context or branch-deploy context -netlify env:list --scope functions -netlify env:list --plain -``` - ---- -## `env:set` - -Set value of environment variable - -**Usage** - -```bash -netlify env:set -``` - -**Arguments** - -- key - Environment variable key -- value - Value to set to - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: all contexts) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Bypasses prompts & Force the command to run. -- `json` (*boolean*) - Output environment variables as JSON -- `scope` (*builds | functions | post-processing | runtime*) - Specify a scope (default: all scopes) -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `secret` (*boolean*) - Indicate whether the environment variable value can be read again. -- `site` (*string*) - A project name or ID to target - -**Examples** - -```bash -netlify env:set VAR_NAME value # set in all contexts and scopes -netlify env:set VAR_NAME value --context production -netlify env:set VAR_NAME value --context production deploy-preview # set in the production and deploy-preview contexts -netlify env:set VAR_NAME value --context branch:feat/make-it-pop # set in the feat/make-it-pop branch context -netlify env:set VAR_NAME value --context production --secret -netlify env:set VAR_NAME value --scope builds -netlify env:set VAR_NAME value --scope builds functions -netlify env:set VAR_NAME --secret # convert existing variable to secret -``` - ---- -## `env:unset` - -Unset an environment variable which removes it from the UI - -**Usage** - -```bash -netlify env:unset -``` - -**Arguments** - -- key - Environment variable key - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: all contexts) -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Bypasses prompts & Force the command to run. -- `json` (*boolean*) - Output environment variables as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `site` (*string*) - A project name or ID to target - -**Examples** - -```bash -netlify env:unset VAR_NAME # unset in all contexts -netlify env:unset VAR_NAME --context production -netlify env:unset VAR_NAME --context production deploy-preview -netlify env:unset VAR_NAME --context branch:feat/make-it-pop # unset in the feat/make-it-pop branch context -``` - ---- - - \ No newline at end of file diff --git a/docs/commands/functions.md b/docs/commands/functions.md deleted file mode 100644 index 9a560a54e0f..00000000000 --- a/docs/commands/functions.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -title: Netlify CLI functions command -sidebar: - label: functions -description: Run netlify dev locally ---- - -# `functions` - - -Manage netlify functions -The `functions` command will help you manage the functions in this project - -**Usage** - -```bash -netlify functions -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`functions:build`](/commands/functions#functionsbuild) | Build functions locally | -| [`functions:create`](/commands/functions#functionscreate) | Create a new function locally | -| [`functions:invoke`](/commands/functions#functionsinvoke) | Trigger a function while in netlify dev with simulated data, good for testing function calls including Netlify's Event Triggered Functions | -| [`functions:list`](/commands/functions#functionslist) | List functions that exist locally | -| [`functions:serve`](/commands/functions#functionsserve) | Serve functions locally | - - -**Examples** - -```bash -netlify functions:create --name function-xyz -netlify functions:build --functions build/to/directory --src source/directory -``` - ---- -## `functions:build` - -Build functions locally - -**Usage** - -```bash -netlify functions:build -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `functions` (*string*) - Specify a functions directory to build to -- `src` (*string*) - Specify the source directory for the functions -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `functions:create` - -Create a new function locally - -**Usage** - -```bash -netlify functions:create -``` - -**Arguments** - -- name - name of your new function file inside your functions directory - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `language` (*string*) - function language -- `name` (*string*) - function name -- `offline` (*boolean*) - Disables any features that require network access -- `template` (*string*) - bundled template to use (skips the interactive template picker) -- `url` (*string*) - pull template from URL -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify functions:create -netlify functions:create hello-world -netlify functions:create --name hello-world -netlify functions:create --language typescript --template hello-world -``` - ---- -## `functions:invoke` - -Trigger a function while in netlify dev with simulated data, good for testing function calls including Netlify's Event Triggered Functions - -**Usage** - -```bash -netlify functions:invoke -``` - -**Arguments** - -- name - function name to invoke - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `functions` (*string*) - Specify a functions folder to parse, overriding netlify.toml -- `identity` (*boolean*) - simulate Netlify Identity authentication JWT. pass --identity to affirm unauthenticated request -- `name` (*string*) - function name to invoke -- `no-identity` (*boolean*) - simulate Netlify Identity authentication JWT. pass --no-identity to affirm unauthenticated request -- `offline` (*boolean*) - Disables any features that require network access -- `payload` (*string*) - Supply POST payload in stringified json, or a path to a json file -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `port` (*string*) - Port where netlify dev is accessible. e.g. 8888 -- `querystring` (*string*) - Querystring to add to your function invocation - -**Examples** - -```bash -netlify functions:invoke -netlify functions:invoke myfunction -netlify functions:invoke --name myfunction -netlify functions:invoke --name myfunction --identity -netlify functions:invoke --name myfunction --no-identity -netlify functions:invoke myfunction --payload '{"foo": 1}' -netlify functions:invoke myfunction --querystring "foo=1 -netlify functions:invoke myfunction --payload "./pathTo.json" -``` - ---- -## `functions:list` - -List functions that exist locally -Helpful for making sure that you have formatted your functions correctly - -NOT the same as listing the functions that have been deployed. For that info you need to go to your Netlify deploy log. - -**Usage** - -```bash -netlify functions:list -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `functions` (*string*) - Specify a functions directory to list -- `json` (*boolean*) - Output function data as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `functions:serve` - -Serve functions locally - -**Usage** - -```bash -netlify functions:serve -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `functions` (*string*) - Specify a functions directory to serve -- `offline` (*boolean*) - Disables any features that require network access -- `port` (*string*) - Specify a port for the functions server -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- - - diff --git a/docs/commands/init.md b/docs/commands/init.md deleted file mode 100644 index 9aa21e7e4fe..00000000000 --- a/docs/commands/init.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Netlify CLI init command -sidebar: - label: init -description: Initialize a new project locally ---- - -# `init` - - -Configure continuous deployment for a new or existing project. To create a new project without continuous deployment, use `netlify sites:create` - -**Usage** - -```bash -netlify init -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Reinitialize CI hooks if the linked project is already configured to use CI -- `git-remote-name` (*string*) - Name of Git remote to use. e.g. "origin" -- `manual` (*boolean*) - Manually configure a git remote for CI -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - - - diff --git a/docs/commands/link.md b/docs/commands/link.md deleted file mode 100644 index 5d1b233e7b6..00000000000 --- a/docs/commands/link.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: Netlify CLI link command -sidebar: - label: link -description: Link an existing project to a local project directory ---- - -# `link` - - -Link a local repo or project folder to an existing project on Netlify - -**Usage** - -```bash -netlify link -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `git-remote-name` (*string*) - Name of Git remote to use. e.g. "origin" -- `git-remote-url` (*string*) - URL of the repository (or Github `owner/repo`) to link to -- `id` (*string*) - ID of project to link to -- `name` (*string*) - Name of project to link to -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify link -netlify link --id 123-123-123-123 -netlify link --name my-project-name -netlify link --git-remote-url https://github.com/vibecoder/my-unicorn.git -``` - - - diff --git a/docs/commands/login.md b/docs/commands/login.md deleted file mode 100644 index 6304e5dceb4..00000000000 --- a/docs/commands/login.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: Netlify CLI login command -sidebar: - label: login -description: Login to your Netlify account ---- - -# `login` - - -Login to your Netlify account -Opens a web browser to acquire an OAuth token. - -**Usage** - -```bash -netlify login -``` - -**Flags** - -- `check` (*string*) - Check the status of a login ticket created with --request -- `json` (*boolean*) - Output as JSON (for use with --request or --check) -- `new` (*boolean*) - Login to new Netlify account -- `request` (*string*) - Create a login ticket for agent/human-in-the-loop auth -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - - - diff --git a/docs/commands/logout.md b/docs/commands/logout.md deleted file mode 100644 index 6591080e2e0..00000000000 --- a/docs/commands/logout.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: Netlify CLI logout command -sidebar: - label: logout -description: Login to your Netlify account -hidden: true ---- - -# `logout` - - -Logout of your Netlify account - -**Usage** - -```bash -netlify logout -``` - diff --git a/docs/commands/logs.md b/docs/commands/logs.md deleted file mode 100644 index 09230084d95..00000000000 --- a/docs/commands/logs.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Netlify CLI logs command -sidebar: - label: logs ---- - -# `logs` - - -View logs from your project - -**Usage** - -```bash -netlify logs -``` - -**Flags** - -- `edge-function` (*string*) - Filter to specific edge functions by name or path -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `follow` (*boolean*) - Stream logs in real time instead of showing historical logs -- `function` (*string*) - Filter to specific functions by name -- `json` (*boolean*) - Output logs as JSON Lines -- `level` (*string*) - Log levels to include. Choices are: trace, debug, info, warn, error, fatal -- `since` (*string*) - Start of the historical log window. Accepts a duration (e.g. 10m, 1h, 24h) or an ISO 8601 timestamp. Defaults to 10m -- `source` (*functions | edge-functions | deploy*) - Log sources to include. Defaults to functions and edge-functions -- `until` (*string*) - End of the historical log window. Accepts a duration or an ISO 8601 timestamp (defaults to now) -- `url` (*string*) - Show logs for the deploy behind the given URL. Supports deploy permalinks and branch subdomains -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify logs -netlify logs --since 1h -netlify logs --source functions --function checkout --since 24h -netlify logs --source edge-functions --since 30m -netlify logs --source deploy --source functions --since 1h -netlify logs --follow -netlify logs --follow --source functions --source edge-functions -netlify logs --json --since 1h -netlify logs --url https://my-branch--my-site.netlify.app --since 1h -``` - - - diff --git a/docs/commands/open.md b/docs/commands/open.md deleted file mode 100644 index fc15acdd7a9..00000000000 --- a/docs/commands/open.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: Netlify CLI open command -sidebar: - label: open ---- - -# `open` - - -Open settings for the project linked to the current folder - -**Usage** - -```bash -netlify open -``` - -**Flags** - -- `admin` (*boolean*) - Open Netlify project -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `site` (*boolean*) - Open project -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`open:admin`](/commands/open#openadmin) | Opens current project admin UI in Netlify | -| [`open:site`](/commands/open#opensite) | Opens current project url in browser | - - -**Examples** - -```bash -netlify open --site -netlify open --admin -netlify open:admin -netlify open:site -``` - ---- -## `open:admin` - -Opens current project admin UI in Netlify - -**Usage** - -```bash -netlify open:admin -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify open:admin -``` - ---- -## `open:site` - -Opens current project url in browser - -**Usage** - -```bash -netlify open:site -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify open:site -``` - ---- - - diff --git a/docs/commands/recipes.md b/docs/commands/recipes.md deleted file mode 100644 index dcd1ed9ced1..00000000000 --- a/docs/commands/recipes.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: Netlify CLI recipes command -sidebar: - label: recipes ---- - -# `recipes` - - -Create and modify files in a project using pre-defined recipes - -**Usage** - -```bash -netlify recipes -``` - -**Arguments** - -- name - name of the recipe - -**Flags** - -- `name` (*string*) - recipe name to use -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`recipes:list`](/commands/recipes#recipeslist) | List the recipes available to create and modify files in a project | - - -**Examples** - -```bash -netlify recipes my-recipe -netlify recipes --name my-recipe -``` - ---- -## `recipes:list` - -List the recipes available to create and modify files in a project - -**Usage** - -```bash -netlify recipes:list -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify recipes:list -``` - ---- - - diff --git a/docs/commands/serve.md b/docs/commands/serve.md deleted file mode 100644 index c2a1141c8cb..00000000000 --- a/docs/commands/serve.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Netlify CLI serve command -sidebar: - label: serve -description: - Build the project for production and serve locally. This does not watch the code for changes, so if you need to rebuild - your project then you must exit and run `serve` again. ---- - -# `serve` - - -Build the project for production and serve locally. This does not watch the code for changes, so if you need to rebuild your project then you must exit and run `serve` again. - -**Usage** - -```bash -netlify serve -``` - -**Flags** - -- `context` (*string*) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) or `branch:your-branch` where `your-branch` is the name of a branch (default: dev) -- `country` (*string*) - Two-letter country code (https://ntl.fyi/country-codes) to use as mock geolocation (enables --geo=mock automatically) -- `dir` (*string*) - dir with static files -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `functions` (*string*) - specify a functions folder to serve -- `functions-port` (*string*) - port of functions server -- `geo` (*cache | mock | update*) - force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location -- `offline` (*boolean*) - Disables any features that require network access -- `port` (*string*) - port of netlify dev -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify serve -BROWSER=none netlify serve # disable browser auto opening -netlify serve --context production # Use env var values from production context -netlify serve --context deploy-preview # Use env var values from deploy-preview context -netlify serve --context branch:feat/make-it-pop # Use env var values from the feat/make-it-pop branch context or branch-deploy context -``` - - - diff --git a/docs/commands/sites.md b/docs/commands/sites.md deleted file mode 100644 index 37dfa2281df..00000000000 --- a/docs/commands/sites.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -title: Netlify CLI sites command -sidebar: - label: sites -description: Manage Netlify projects via the command line ---- - -# `sites` - - -Handle various project operations -The sites command will help you manage all your projects - -**Usage** - -```bash -netlify sites -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`sites:create`](/commands/sites#sitescreate) | Create an empty project (advanced) | -| [`sites:delete`](/commands/sites#sitesdelete) | Delete a project | -| [`sites:list`](/commands/sites#siteslist) | List all projects you have access to | -| [`sites:search`](/commands/sites#sitessearch) | Search for projects by name | - - -**Examples** - -```bash -netlify sites:create --name my-new-project -netlify sites:list -``` - ---- -## `sites:create` - -Create an empty project (advanced) -Create a blank project that isn't associated with any git remote. Will link the project to the current working directory. - -**Usage** - -```bash -netlify sites:create -``` - -**Flags** - -- `account-slug` (*string*) - account slug to create the project under -- `disable-linking` (*boolean*) - create the project without linking it to current directory -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output project data as JSON -- `manual` (*boolean*) - force manual CI setup. Used --with-ci flag -- `name` (*string*) - name of project -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in -- `prompt` (*string*) - description of the site to create (delegates to `netlify create`) -- `with-ci` (*boolean*) - initialize CI hooks during project creation - ---- -## `sites:delete` - -Delete a project -This command will permanently delete the project on Netlify. Use with caution. - -**Usage** - -```bash -netlify sites:delete -``` - -**Arguments** - -- id - Project ID to delete. - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `force` (*boolean*) - Delete without prompting (useful for CI). -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify sites:delete 1234-3262-1211 -``` - ---- -## `sites:list` - -List all projects you have access to - -**Usage** - -```bash -netlify sites:list -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output project data as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- -## `sites:search` - -Search for projects by name - -**Usage** - -```bash -netlify sites:search -``` - -**Arguments** - -- search-term - Full or partial project name to search for - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output project data as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify sites:search my-project -netlify sites:search "partial name" --json -``` - ---- - - diff --git a/docs/commands/status.md b/docs/commands/status.md deleted file mode 100644 index 9529891046a..00000000000 --- a/docs/commands/status.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: Netlify CLI status command -sidebar: - label: status -description: Get the current context of the netlify CLI ---- - -# `status` - - -Print status information - -**Usage** - -```bash -netlify status -``` - -**Flags** - -- `json` (*boolean*) - Output status information as JSON -- `verbose` (*boolean*) - Output system info -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`status:hooks`](/commands/status#statushooks) | Print hook information of the linked project | - - ---- -## `status:hooks` - -Print hook information of the linked project - -**Usage** - -```bash -netlify status:hooks -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - ---- - - diff --git a/docs/commands/switch.md b/docs/commands/switch.md deleted file mode 100644 index 8d08756d7c1..00000000000 --- a/docs/commands/switch.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: Netlify CLI switch command -sidebar: - label: switch -description: Switch your active Netlify account ---- - -# `switch` - - -Switch your active Netlify account - -**Usage** - -```bash -netlify switch -``` - -**Flags** - -- `email` (*string*) - Switch to the account matching this email address -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - - - diff --git a/docs/commands/teams.md b/docs/commands/teams.md deleted file mode 100644 index db255b2e877..00000000000 --- a/docs/commands/teams.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: Netlify CLI teams command -sidebar: - label: teams -description: Manage Netlify teams via the command line ---- - -# `teams` - - -Handle various team operations -The teams command will help you manage your teams - -**Usage** - -```bash -netlify teams -``` - -**Flags** - -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -| Subcommand | description | -|:--------------------------- |:-----| -| [`teams:list`](/commands/teams#teamslist) | List all teams you have access to | - - -**Examples** - -```bash -netlify teams:list -``` - ---- -## `teams:list` - -List all teams you have access to - -**Usage** - -```bash -netlify teams:list -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `json` (*boolean*) - Output team data as JSON -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify teams:list -netlify teams:list --json -``` - ---- - - diff --git a/docs/commands/unlink.md b/docs/commands/unlink.md deleted file mode 100644 index 030a0506d15..00000000000 --- a/docs/commands/unlink.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: Netlify CLI unlink command -sidebar: - label: unlink -description: Unlink a local project directory from an existing project ---- - -# `unlink` - - -Unlink a local folder from a Netlify project - -**Usage** - -```bash -netlify unlink -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - - - diff --git a/docs/commands/watch.md b/docs/commands/watch.md deleted file mode 100644 index ac7062847d5..00000000000 --- a/docs/commands/watch.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: Netlify CLI watch command -sidebar: - label: watch -description: Watch for project deploy to finish ---- - -# `watch` - - -Watch for project deploy to finish - -**Usage** - -```bash -netlify watch -``` - -**Flags** - -- `filter` (*string*) - For monorepos, specify the name of the application to run the command in -- `debug` (*boolean*) - Print debugging information -- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in - -**Examples** - -```bash -netlify watch -git push && netlify watch -``` - - - diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 00000000000..eafcc161cfb --- /dev/null +++ b/docs/index.html @@ -0,0 +1,112 @@ + + + + + + Netlify CLI + + + +
+

The app is the CLI.

+

Try the interactive agent

+
git clone https://github.com/netlify/cli.git
+cd cli
+npm install
+npm run build
+node bin/run.js agents:interactive
+
+ + diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 2a0899110d5..00000000000 --- a/docs/index.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -title: Netlify CLI command reference -description: All Netlify CLI commands ---- - -To get a list of commands, run - -``` -netlify help -``` - -To get a list of available sub-commands, arguments & flags run - -``` -netlify [command] help -``` - -## Commands - - -### [agents](/commands/agents) - -Manage Netlify AI agent tasks - -| Subcommand | description | -|:--------------------------- |:-----| -| [`agents:create`](/commands/agents#agentscreate) | Create and run a new agent task on your site | -| [`agents:list`](/commands/agents#agentslist) | List agent tasks for the current site | -| [`agents:show`](/commands/agents#agentsshow) | Show details of a specific agent task | -| [`agents:stop`](/commands/agents#agentsstop) | Stop a running agent task | - - -### [api](/commands/api) - -Run any Netlify API method - -### [blobs](/commands/blobs) - -Manage objects in Netlify Blobs - -| Subcommand | description | -|:--------------------------- |:-----| -| [`blobs:delete`](/commands/blobs#blobsdelete) | Deletes an object with a given key, if it exists, from a Netlify Blobs store | -| [`blobs:get`](/commands/blobs#blobsget) | Reads an object with a given key from a Netlify Blobs store and, if it exists, prints the content to the terminal or saves it to a file | -| [`blobs:list`](/commands/blobs#blobslist) | Lists objects in a Netlify Blobs store | -| [`blobs:set`](/commands/blobs#blobsset) | Writes to a Netlify Blobs store an object with the data provided in the command or the contents of a file defined by the 'input' parameter | - - -### [build](/commands/build) - -Build on your local machine - -### [claim](/commands/claim) - -Claim an anonymously deployed site and link it to your account - -### [clone](/commands/clone) - -Clone a remote repository and link it to an existing project on Netlify - -### [completion](/commands/completion) - -Generate shell completion script - -| Subcommand | description | -|:--------------------------- |:-----| -| [`completion:install`](/commands/completion#completioninstall) | Generates completion script for your preferred shell | - - -### [create](/commands/create) - -Create a new Netlify project using an AI agent - -### [database](/commands/database) - -Provision a production ready Postgres database with a single command - -| Subcommand | description | -|:--------------------------- |:-----| -| [`database status`](/commands/database#database-status) | Check the status of the database, including applied and pending migrations | -| [`database init`](/commands/database#database-init) | Interactive setup: install the package, scaffold a starter migration, and verify the database | -| [`database connect`](/commands/database#database-connect) | Connect to the database | -| [`database reset`](/commands/database#database-reset) | Reset the local development database, removing all data and tables | -| [`database migrations`](/commands/database#database-migrations) | Manage database migrations | - - -### [deploy](/commands/deploy) - -Deploy your project to Netlify - -### [dev](/commands/dev) - -Local dev server - -| Subcommand | description | -|:--------------------------- |:-----| -| [`dev:exec`](/commands/dev#devexec) | Runs a command within the netlify dev environment. For example, with environment variables from any installed add-ons | - - -### [env](/commands/env) - -Control environment variables for the current project - -| Subcommand | description | -|:--------------------------- |:-----| -| [`env:clone`](/commands/env#envclone) | Clone environment variables from one project to another | -| [`env:get`](/commands/env#envget) | Get resolved value of specified environment variable (includes netlify.toml) | -| [`env:import`](/commands/env#envimport) | Import and set environment variables from .env file | -| [`env:list`](/commands/env#envlist) | Lists resolved environment variables for project (includes netlify.toml) | -| [`env:set`](/commands/env#envset) | Set value of environment variable | -| [`env:unset`](/commands/env#envunset) | Unset an environment variable which removes it from the UI | - - -### [functions](/commands/functions) - -Manage netlify functions - -| Subcommand | description | -|:--------------------------- |:-----| -| [`functions:build`](/commands/functions#functionsbuild) | Build functions locally | -| [`functions:create`](/commands/functions#functionscreate) | Create a new function locally | -| [`functions:invoke`](/commands/functions#functionsinvoke) | Trigger a function while in netlify dev with simulated data, good for testing function calls including Netlify's Event Triggered Functions | -| [`functions:list`](/commands/functions#functionslist) | List functions that exist locally | -| [`functions:serve`](/commands/functions#functionsserve) | Serve functions locally | - - -### [init](/commands/init) - -Configure continuous deployment for a new or existing project. To create a new project without continuous deployment, use `netlify sites:create` - -### [link](/commands/link) - -Link a local repo or project folder to an existing project on Netlify - -### [login](/commands/login) - -Login to your Netlify account - -### [logs](/commands/logs) - -View logs from your project - -### [open](/commands/open) - -Open settings for the project linked to the current folder - -| Subcommand | description | -|:--------------------------- |:-----| -| [`open:admin`](/commands/open#openadmin) | Opens current project admin UI in Netlify | -| [`open:site`](/commands/open#opensite) | Opens current project url in browser | - - -### [recipes](/commands/recipes) - -Create and modify files in a project using pre-defined recipes - -| Subcommand | description | -|:--------------------------- |:-----| -| [`recipes:list`](/commands/recipes#recipeslist) | List the recipes available to create and modify files in a project | - - -### [serve](/commands/serve) - -Build the project for production and serve locally. This does not watch the code for changes, so if you need to rebuild your project then you must exit and run `serve` again. - -### [sites](/commands/sites) - -Handle various project operations - -| Subcommand | description | -|:--------------------------- |:-----| -| [`sites:create`](/commands/sites#sitescreate) | Create an empty project (advanced) | -| [`sites:delete`](/commands/sites#sitesdelete) | Delete a project | -| [`sites:list`](/commands/sites#siteslist) | List all projects you have access to | -| [`sites:search`](/commands/sites#sitessearch) | Search for projects by name | - - -### [status](/commands/status) - -Print status information - -| Subcommand | description | -|:--------------------------- |:-----| -| [`status:hooks`](/commands/status#statushooks) | Print hook information of the linked project | - - -### [switch](/commands/switch) - -Switch your active Netlify account - -### [teams](/commands/teams) - -Handle various team operations - -| Subcommand | description | -|:--------------------------- |:-----| -| [`teams:list`](/commands/teams#teamslist) | List all teams you have access to | - - -### [unlink](/commands/unlink) - -Unlink a local folder from a Netlify project - -### [watch](/commands/watch) - -Watch for project deploy to finish - - - diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 00000000000..e00fd067ed8 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,3 @@ +[build] + command = "echo 'true'" + publish = "docs/" diff --git a/src/commands/agents/agents-interactive.ts b/src/commands/agents/agents-interactive.ts new file mode 100644 index 00000000000..deb8d45216c --- /dev/null +++ b/src/commands/agents/agents-interactive.ts @@ -0,0 +1,394 @@ +import readline from 'readline' + +import type { OptionValues } from 'commander' + +import { chalk, exit, log, logAndThrowError } from '../../utils/command-helpers.js' +import { startSpinner, stopSpinner, clearSpinner, type Spinner } from '../../lib/spinner.js' +import type BaseCommand from '../base-command.js' +import type { AgentRunner, AgentRunnerSession } from './types.js' +import { formatStatus, getAgentName, validatePrompt } from './utils.js' + +interface AgentInteractiveOptions extends OptionValues { + agent?: string + model?: string + run?: string +} + +const POLL_INTERVAL_MS = 3000 +const TERMINAL_SESSION_STATES = new Set(['done', 'error', 'cancelled']) + +const delay = (ms: number): Promise => new Promise((resolve) => setTimeout(resolve, ms)) + +interface RequestContext { + baseUrl: string + accessToken: string + userAgent: string +} + +const buildRequestContext = (command: BaseCommand): RequestContext => { + const { api, apiOpts } = command.netlify + return { + baseUrl: `${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}`, + accessToken: api.accessToken ?? '', + userAgent: apiOpts.userAgent, + } +} + +interface RequestOptions { + method?: string + body?: string + headers?: Record +} + +const request = async (ctx: RequestContext, path: string, init: RequestOptions = {}): Promise => { + const response = await fetch(`${ctx.baseUrl}${path}`, { + method: init.method, + body: init.body, + headers: { + Authorization: `Bearer ${ctx.accessToken}`, + 'User-Agent': ctx.userAgent, + ...init.headers, + }, + }) + + if (!response.ok) { + const errorData = (await response.json().catch(() => ({}))) as { error?: string } + throw new Error(errorData.error ?? `HTTP ${response.status.toString()}: ${response.statusText}`) + } + + return response.status === 204 ? undefined : await response.json().catch(() => undefined) +} + +const createRun = async (ctx: RequestContext, siteId: string, body: Record): Promise => { + const params = new URLSearchParams({ site_id: siteId }) + return (await request(ctx, `/api/v1/agent_runners?${params.toString()}`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + })) as AgentRunner +} + +const createFollowUpSession = async ( + ctx: RequestContext, + runnerId: string, + body: Record, +): Promise => { + await request(ctx, `/api/v1/agent_runners/${runnerId}/sessions`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + }) +} + +const getRun = async (ctx: RequestContext, runnerId: string): Promise => + (await request(ctx, `/api/v1/agent_runners/${runnerId}`)) as AgentRunner + + +const getLatestSession = async (ctx: RequestContext, runnerId: string): Promise => { + const sessions = (await request(ctx, `/api/v1/agent_runners/${runnerId}/sessions?page=1&per_page=1`)) as + | AgentRunnerSession[] + | undefined + return sessions?.[0] +} + +const printSessionResult = (session: AgentRunnerSession): void => { + log('') + if (session.state === 'done') { + log(`${chalk.green('✓')} ${chalk.bold(session.title ?? 'Session complete')}`) + if (session.result) { + log('') + log(session.result) + } + } else if (session.state === 'error') { + log(`${chalk.red('✗')} ${chalk.bold('The agent ran into an error.')}`) + if (session.result) { + log('') + log(session.result) + } + } else { + log(`${chalk.yellow('•')} ${chalk.bold('The session was cancelled.')}`) + } + log('') +} + +const waitForSession = async ( + ctx: RequestContext, + runnerId: string, + predicate: (session: AgentRunnerSession) => boolean, +): Promise => { + let session = await getLatestSession(ctx, runnerId) + while (!session || !predicate(session)) { + await delay(POLL_INTERVAL_MS) + session = await getLatestSession(ctx, runnerId) + } + return session +} + +const printStep = (step: { title?: string; message?: string }): void => { + const title = step.title?.trim() + const message = step.message?.trim() + + if (title) { + log(`${chalk.cyan('│')} ${chalk.bold(title)}`) + if (message && message !== title) { + log(chalk.dim(`│ ${message}`)) + } + } else if (message) { + log(`${chalk.cyan('│')} ${message}`) + } +} + +const followSession = async ( + ctx: RequestContext, + runnerId: string, + currentSession: AgentRunnerSession, +): Promise => { + const spinner = startSpinner({ text: 'The agent is getting started…' }) + let printedSteps = 0 + let lastTask: string | undefined + let session = currentSession + + const streamSteps = (steps: NonNullable): void => { + const fresh = steps.slice(printedSteps) + if (fresh.length === 0) { + return + } + + clearSpinner({ spinner }) + for (const step of fresh) { + printStep(step) + } + printedSteps = steps.length + + const latest = steps[steps.length - 1] + spinner.update({ text: latest.title ?? latest.message ?? 'Working…' }) + } + + const streamTask = (task: string | undefined): void => { + const trimmed = task?.trim() + if (!trimmed || trimmed === lastTask) { + return + } + lastTask = trimmed + + clearSpinner({ spinner }) + log(`${chalk.cyan('│')} ${trimmed}`) + spinner.update({ text: trimmed }) + } + + try { + streamSteps(session.steps ?? []) + + while (!TERMINAL_SESSION_STATES.has(session.state)) { + const runner = await getRun(ctx, runnerId).catch(() => undefined) + if (runner) { + streamTask(runner.current_task) + } + + await delay(POLL_INTERVAL_MS) + + const next = await getLatestSession(ctx, runnerId) + if (next) { + session = next + streamSteps(session.steps ?? []) + } + } + + stopSpinner({ spinner }) + } catch (error) { + stopSpinner({ spinner, error: true }) + throw error + } + + printSessionResult(session) + return session +} + +const MULTILINE_HINT = 'Enter to submit · Ctrl+Enter or Shift+Enter for a new line' +const ESC = '' +const SAVE_CURSOR = `${ESC}7` +const RESTORE_CURSOR = `${ESC}8` +const CLEAR_TO_END = `${ESC}[0J` + +const readMultilineInput = (message: string): Promise => { + const { stdin, stdout } = process + + if (!stdin.isTTY) { + return new Promise((resolve) => { + const rl = readline.createInterface({ input: stdin }) + stdout.write(`${message}\n`) + rl.once('line', (line) => { + rl.close() + resolve(line) + }) + }) + } + + return new Promise((resolve) => { + readline.emitKeypressEvents(stdin) + const wasRaw = stdin.isRaw + stdin.setRawMode(true) + stdin.resume() + + stdout.write(`${chalk.bold(message)}\n`) + stdout.write(`${chalk.dim(MULTILINE_HINT)}\n`) + stdout.write(chalk.cyan('> ')) + stdout.write(SAVE_CURSOR) + + let buffer = '' + + const render = () => { + stdout.write(RESTORE_CURSOR) + stdout.write(CLEAR_TO_END) + stdout.write(buffer.replace(/\n/g, '\r\n')) + } + + const cleanup = () => { + stdin.removeListener('keypress', onKeypress) + stdin.setRawMode(wasRaw) + stdin.pause() + } + + const onKeypress = (str: string | undefined, key: readline.Key) => { + if (key.ctrl && key.name === 'c') { + cleanup() + stdout.write('\r\n') + exit(130) + } + + const isSubmit = key.name === 'return' && !key.ctrl && !key.shift && !key.meta + const isNewline = + str === '\n' || key.name === 'enter' || (key.name === 'return' && (key.ctrl === true || key.shift === true)) + + if (isSubmit) { + render() + stdout.write('\r\n') + cleanup() + resolve(buffer) + return + } + + if (isNewline) { + buffer += '\n' + render() + return + } + + if (key.name === 'backspace') { + buffer = buffer.slice(0, -1) + render() + return + } + + if (str !== undefined && !key.ctrl && !key.meta) { + buffer += str.replace(/\r\n?/g, '\n') + render() + } + } + + stdin.on('keypress', onKeypress) + }) +} + +const askPrompt = async (message: string): Promise => { + const input = await readMultilineInput(message) + return input.trim() +} + +export const agentsInteractive = async (options: AgentInteractiveOptions, command: BaseCommand) => { + const { site, siteInfo } = command.netlify + + await command.authenticate() + + const ctx = buildRequestContext(command) + const siteId = site.id ?? '' + const agent = options.agent ?? 'claude' + const model = options.model + const isGitBased = Boolean(siteInfo.build_settings?.repo_branch) + const branch = isGitBased ? siteInfo.build_settings?.repo_branch : undefined + const attachRunId = options.run + + console.clear() + log(chalk.bold(`Welcome to the Netlify agent for ${chalk.cyan(siteInfo.name)}.`)) + log(chalk.dim(`Running ${getAgentName(agent)} on ${isGitBased ? `branch ${branch ?? ''}` : 'your production deployment'}.`)) + log('') + + const initialPrompt = await askPrompt('What do you want to build today?') + const initialPromptIsValid = validatePrompt(initialPrompt) + if (initialPromptIsValid !== true) { + return logAndThrowError(initialPromptIsValid) + } + + let runner: AgentRunner + let firstSessionPredicate: (session: AgentRunnerSession) => boolean + + if (attachRunId) { + const attachSpinner: Spinner = startSpinner({ text: `Attaching to agent run ${attachRunId}…` }) + try { + runner = await getRun(ctx, attachRunId) + const existingSession = await getLatestSession(ctx, runner.id) + const baselineSessionId = existingSession?.id + await createFollowUpSession(ctx, runner.id, { prompt: initialPrompt, agent, model }) + stopSpinner({ spinner: attachSpinner }) + firstSessionPredicate = (session) => session.id !== baselineSessionId + } catch (error_) { + stopSpinner({ spinner: attachSpinner, error: true }) + return logAndThrowError(`Failed to attach to agent run: ${(error_ as Error).message}`) + } + } else { + const createRunSpinner: Spinner = startSpinner({ text: 'Spinning up a new agent run…' }) + try { + runner = await createRun(ctx, siteId, { + ...(branch ? { branch } : {}), + prompt: initialPrompt, + agent, + model, + }) + stopSpinner({ spinner: createRunSpinner }) + firstSessionPredicate = () => true + } catch (error_) { + stopSpinner({ spinner: createRunSpinner, error: true }) + return logAndThrowError(`Failed to start agent run: ${(error_ as Error).message}`) + } + } + + log(chalk.dim(`Run ${chalk.cyan(runner.id)} — ${formatStatus(runner.state ?? 'new')}`)) + + try { + const firstSession = await waitForSession(ctx, runner.id, firstSessionPredicate) + const completed = await followSession(ctx, runner.id, firstSession) + + let previousSessionId = completed.id + + const isExit = (input: string): boolean => input === '' || input.toLowerCase() === 'exit' + + let followUp = await askPrompt("What's next? (press Enter or type 'exit' to finish)") + while (!isExit(followUp)) { + const startSessionSpinner = startSpinner({ text: 'Sending your follow-up to the agent…' }) + try { + await createFollowUpSession(ctx, runner.id, { prompt: followUp, agent, model }) + stopSpinner({ spinner: startSessionSpinner }) + + const newSession = await waitForSession(ctx, runner.id, (candidate) => candidate.id !== previousSessionId) + const finished = await followSession(ctx, runner.id, newSession) + previousSessionId = finished.id + } catch (error_) { + stopSpinner({ spinner: startSessionSpinner, error: true }) + log(chalk.red(`Failed to send follow-up: ${(error_ as Error).message}`)) + } + + followUp = await askPrompt("What's next? (press Enter or type 'exit' to finish)") + } + } catch (error_) { + return logAndThrowError(`Agent run failed: ${(error_ as Error).message}`) + } + + log('') + log(chalk.dim('Thanks for building with Netlify. Picking this run back up any time:')) + log(` ${chalk.cyan(`netlify agents:show ${runner.id}`)}`) + log( + ` ${chalk.blue(`https://app.netlify.com/projects/${siteInfo.name}/agent-runs/${runner.id}`)}`, + ) + + return runner +} diff --git a/src/commands/agents/agents.ts b/src/commands/agents/agents.ts index b139a133119..e224cd9b4b0 100644 --- a/src/commands/agents/agents.ts +++ b/src/commands/agents/agents.ts @@ -33,6 +33,24 @@ export const createAgentsCommand = (program: BaseCommand) => { await agentsCreate(prompt, options, command) }) + program + .command('agents:interactive') + .description('Start an interactive session to build with an agent on your site') + .option('-a, --agent ', 'agent type (claude, codex, gemini)', 'claude') + .option('-m, --model ', 'model to use for the agent') + .option('--run ', 'attach to an existing agent run instead of starting a new one') + .option('--project ', 'project ID or name (if not in a linked directory)') + .hook('preAction', requiresSiteInfoWithProject) + .addExamples([ + 'netlify agents:interactive', + 'netlify agents:interactive --agent claude', + 'netlify agents:interactive --run 60c7c3b3e7b4a0001f5e4b3a', + ]) + .action(async (options: OptionValues, command: BaseCommand) => { + const { agentsInteractive } = await import('./agents-interactive.js') + await agentsInteractive(options, command) + }) + program .command('agents:list') .description('List agent tasks for the current site')