Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/commands/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

**Flags**

- `agent` (*string*) - agent type (claude, codex, gemini)
- `agent` (*string*) - agent type (claude, codex, antigravity)

Check warning on line 61 in docs/commands/agents.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [base.spelling] Spellcheck: did you really mean 'claude'? Raw Output: {"message": "[base.spelling] Spellcheck: did you really mean 'claude'?", "location": {"path": "docs/commands/agents.md", "range": {"start": {"line": 61, "column": 36}}}, "severity": "WARNING"}
- `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
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
**Flags**

- `account-slug` (*string*) - account slug to create the project under
- `agent` (*string*) - agent type (claude, codex, gemini)
- `agent` (*string*) - agent type (claude, codex, antigravity)

Check warning on line 26 in docs/commands/create.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [base.spelling] Spellcheck: did you really mean 'claude'? Raw Output: {"message": "[base.spelling] Spellcheck: did you really mean 'claude'?", "location": {"path": "docs/commands/create.md", "range": {"start": {"line": 26, "column": 36}}}, "severity": "WARNING"}
- `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)
Expand Down
3 changes: 2 additions & 1 deletion src/commands/agents/agents-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { chalk, logAndThrowError, log, logJson } from '../../utils/command-helpe
import { startSpinner, stopSpinner } from '../../lib/spinner.js'
import type BaseCommand from '../base-command.js'
import type { AgentRunner } from './types.js'
import { validatePrompt, validateAgent, formatStatus, getAgentName } from './utils.js'
import { validatePrompt, validateAgent, formatStatus, getAgentName, resolveAgentAlias } from './utils.js'
import { AVAILABLE_AGENTS } from './constants.js'

interface AgentCreateOptions extends OptionValues {
Expand Down Expand Up @@ -51,6 +51,7 @@ export const agentsCreate = async (promptArg: string, options: AgentCreateOption
default: 'claude',
})
} else {
agent = resolveAgentAlias(agent)
const agentIsValid = validateAgent(agent)
if (agentIsValid !== true) {
return logAndThrowError(agentIsValid)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/agents/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createAgentsCommand = (program: BaseCommand) => {
.argument('[prompt]', 'the prompt for the agent to execute')
.description('Create and run a new agent task on your site')
.option('-p, --prompt <prompt>', 'agent prompt')
.option('-a, --agent <agent>', 'agent type (claude, codex, gemini)')
.option('-a, --agent <agent>', 'agent type (claude, codex, antigravity)')
.option('-m, --model <model>', 'model to use for the agent')
.option('-b, --branch <branch>', 'git branch to work on')
.option('--project <project>', 'project ID or name (if not in a linked directory)')
Expand Down
9 changes: 8 additions & 1 deletion src/commands/agents/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ import { chalk } from '../../utils/command-helpers.js'
export const AVAILABLE_AGENTS = [
{ name: 'Claude', value: 'claude' },
{ name: 'Codex', value: 'codex' },
{ name: 'Gemini', value: 'gemini' },
{ name: 'Antigravity', value: 'antigravity' },
] as const

/**
* Agent names that are still accepted and mapped to their replacement
*/
export const DEPRECATED_AGENT_ALIASES: Record<string, AvailableAgent> = {
gemini: 'antigravity',
}

/**
* Valid agent task states
*/
Expand Down
13 changes: 11 additions & 2 deletions src/commands/agents/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AVAILABLE_AGENTS, STATUS_COLORS } from './constants.js'
import { chalk } from '../../utils/command-helpers.js'
import { AVAILABLE_AGENTS, DEPRECATED_AGENT_ALIASES, STATUS_COLORS } from './constants.js'
import { chalk, warn } from '../../utils/command-helpers.js'

export const truncateText = (text: string, maxLength: number): string => {
if (text.length <= maxLength) return text
Expand Down Expand Up @@ -44,6 +44,15 @@ export const validatePrompt = (input: string): boolean | string => {
return true
}

export const resolveAgentAlias = (agent: string): string => {
if (!Object.hasOwn(DEPRECATED_AGENT_ALIASES, agent)) {
return agent
}
const replacement = DEPRECATED_AGENT_ALIASES[agent]
warn(`The "${agent}" agent is deprecated, using "${replacement}" instead.`)
return replacement
}

export const validateAgent = (agent: string): boolean | string => {
const validAgents = AVAILABLE_AGENTS.map((a) => a.value) as string[]
if (!validAgents.includes(agent)) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/create/create-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { track } from '../../utils/telemetry/index.js'
import { extractZip } from '../../utils/zip.js'
import type BaseCommand from '../base-command.js'
import type { AgentRunner } from '../agents/types.js'
import { validatePrompt, validateAgent, formatStatus } from '../agents/utils.js'
import { validatePrompt, validateAgent, formatStatus, resolveAgentAlias } from '../agents/utils.js'
import type { SiteInfo } from '../../utils/types.js'

const execFile = promisify(execFileCb)
Expand Down Expand Up @@ -266,7 +266,7 @@ export const createAction = async (promptArg: string, options: CreateOptions, co
}

// Resolve agent (default to claude)
const agent = initialAgent ?? 'claude'
const agent = resolveAgentAlias(initialAgent ?? 'claude')
const agentIsValid = validateAgent(agent)
if (agentIsValid !== true) {
return logAndThrowError(agentIsValid)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/create/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const createCreateCommand = (program: BaseCommand) => {
.description('Create a new Netlify project using an AI agent')
.argument('[prompt]', 'description of the site to create')
.option('-p, --prompt <prompt>', 'description of the site to create')
.option('--agent <agent>', 'agent type (claude, codex, gemini)')
.option('--agent <agent>', 'agent type (claude, codex, antigravity)')
.option('-m, --model <model>', 'model to use for the agent')
.option('-n, --name <name>', 'project name (subdomain)', validateSiteName)
.option('-d, --dir <path>', 'directory to create the project in (defaults to current directory)')
Expand Down
66 changes: 66 additions & 0 deletions tests/integration/commands/agents/agents-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,72 @@ describe('agents:create command', () => {
})
})

test('should list the available agents when the agent is invalid', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder.build()

await withMockApi(baseRoutes, async ({ apiUrl }) => {
await expect(
callCli(['agents:create', 'Create a form', '--agent', 'nonsense'], getCLIOptions({ apiUrl, builder })),
).rejects.toThrow(/Invalid agent\. Available agents: claude, codex, antigravity$/m)
})
})
})

test('should send the antigravity agent in the create request', async (t) => {
const routes = [
...baseRoutes,
{
path: 'agent_runners',
method: 'POST' as const,
response: mockAgentRunner,
},
]

await withSiteBuilder(t, async (builder) => {
await builder.build()

await withMockApi(routes, async ({ apiUrl, requests }) => {
const cliResponse = (await callCli(
['agents:create', 'Create a login form', '--agent', 'antigravity', '--branch', 'main'],
getCLIOptions({ apiUrl, builder }),
)) as string

expect(cliResponse).toContain('Agent task created successfully!')
expect(cliResponse).not.toContain('deprecated')
const createRequest = requests.find((r) => r.path === '/api/v1/agent_runners' && r.method === 'POST')
expect(createRequest?.body).toEqual(expect.objectContaining({ agent: 'antigravity' }))
})
})
})

test('should map the deprecated gemini agent to antigravity with a warning', async (t) => {
const routes = [
...baseRoutes,
{
path: 'agent_runners',
method: 'POST' as const,
response: mockAgentRunner,
},
]

await withSiteBuilder(t, async (builder) => {
await builder.build()

await withMockApi(routes, async ({ apiUrl, requests }) => {
const cliResponse = (await callCli(
['agents:create', 'Create a login form', '--agent', 'gemini', '--branch', 'main'],
getCLIOptions({ apiUrl, builder }),
)) as string

expect(cliResponse).toContain('The "gemini" agent is deprecated, using "antigravity" instead')
expect(cliResponse).toContain('Agent task created successfully!')
const createRequest = requests.find((r) => r.path === '/api/v1/agent_runners' && r.method === 'POST')
expect(createRequest?.body).toEqual(expect.objectContaining({ agent: 'antigravity' }))
})
})
})

test('should handle authentication errors', async (t) => {
const routes = [
...baseRoutes,
Expand Down
48 changes: 48 additions & 0 deletions tests/integration/commands/create/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,54 @@ describe('create command', () => {
})
})

describe('--agent flag', () => {
test('should send the antigravity agent in the agent runner request', async (t) => {
const routes = [
...baseRoutes,
{ path: 'test-account/sites', method: 'POST' as const, response: mockCreatedSite },
{ path: 'agent_runners', method: 'POST' as const, response: mockAgentRunner },
]

await withSiteBuilder(t, async (builder) => {
await builder.build()

await withMockApi(routes, async ({ apiUrl, requests }) => {
const cliResponse = (await callCli(
['create', 'Build a site', '--agent', 'antigravity', '--no-wait', '--account-slug', 'test-account'],
getCLIOptions({ apiUrl, builder, env: { NETLIFY_SITE_ID: '' } }),
)) as string

expect(cliResponse).not.toContain('deprecated')
const agentRunnerRequest = requests.find((r) => r.path === '/api/v1/agent_runners' && r.method === 'POST')
expect(agentRunnerRequest?.body).toEqual(expect.objectContaining({ agent: 'antigravity' }))
})
})
})

test('should map the deprecated gemini agent to antigravity with a warning', async (t) => {
const routes = [
...baseRoutes,
{ path: 'test-account/sites', method: 'POST' as const, response: mockCreatedSite },
{ path: 'agent_runners', method: 'POST' as const, response: mockAgentRunner },
]

await withSiteBuilder(t, async (builder) => {
await builder.build()

await withMockApi(routes, async ({ apiUrl, requests }) => {
const cliResponse = (await callCli(
['create', 'Build a site', '--agent', 'gemini', '--no-wait', '--account-slug', 'test-account'],
getCLIOptions({ apiUrl, builder, env: { NETLIFY_SITE_ID: '' } }),
)) as string

expect(cliResponse).toContain('The "gemini" agent is deprecated, using "antigravity" instead')
const agentRunnerRequest = requests.find((r) => r.path === '/api/v1/agent_runners' && r.method === 'POST')
expect(agentRunnerRequest?.body).toEqual(expect.objectContaining({ agent: 'antigravity' }))
})
})
})
})

describe('interactive prompts', () => {
test('should prompt for input when no prompt argument given', async (t) => {
const routes = [
Expand Down
Loading