Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/commands/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ netlify init
- `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
- `skip-agent-setup` (*boolean*) - Skip installing Netlify skills for AI coding agents into the project
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

Expand Down
3 changes: 2 additions & 1 deletion src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const createInitCommand = (program: BaseCommand) =>
)
.option('-m, --manual', 'Manually configure a git remote for CI')
.option('--git-remote-name <name>', 'Name of Git remote to use. e.g. "origin"')
.option('--skip-agent-setup', 'Skip installing Netlify skills for AI coding agents into the project')
.addHelpText('after', () => {
const docsUrl = 'https://docs.netlify.com/cli/get-started/'
return `
Expand All @@ -19,5 +20,5 @@ For more information about getting started with Netlify CLI, see ${terminalLink(
})
.action(async (options: OptionValues, command: BaseCommand) => {
const { init } = await import('./init.js')
await init(options, command)
await init(options, command, { setupAgentSkills: !options.skipAgentSetup })
})
25 changes: 23 additions & 2 deletions src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type BaseCommand from '../base-command.js'
import { link } from '../link/link.js'
import { sitesCreate } from '../sites/sites-create.js'
import type { LocalState, SiteInfo } from '../../utils/types.js'
import { setupAgentSkills } from '../../utils/init/agent-skills.js'
import { getBuildSettings, saveNetlifyToml } from '../../utils/init/utils.js'
import { type InitExitCode, LINKED_EXISTING_SITE_EXIT_CODE, LINKED_NEW_SITE_EXIT_CODE } from './constants.js'

Expand Down Expand Up @@ -223,14 +224,30 @@ type InitExitMessageCustomizer = (code: InitExitCode, defaultMessage: string) =>
type InitExtraOptions = {
customizeExitMessage?: InitExitMessageCustomizer | undefined
exitAfterConfiguringRepo?: boolean | undefined
setupAgentSkills?: boolean | undefined
}

const installAgentSkills = async (command: BaseCommand): Promise<void> => {
log()
const result = await setupAgentSkills({ workingDir: command.netlify.repositoryRoot })
await track('sites_agentSkillsSetup', {
installed: result.installed,
directories: result.directories,
skillsVersion: result.skillsVersion,
...result.summary,
})
}

export const init = async (
options: OptionValues,
command: BaseCommand,
{ customizeExitMessage, exitAfterConfiguringRepo = false }: InitExtraOptions = {},
{
customizeExitMessage,
exitAfterConfiguringRepo = false,
setupAgentSkills: shouldSetupAgentSkills = false,
}: InitExtraOptions = {},
): Promise<SiteInfo> => {
command.setAnalyticsPayload({ manual: options.manual, force: options.force })
command.setAnalyticsPayload({ manual: options.manual, force: options.force, skipAgentSetup: options.skipAgentSetup })

const { repositoryRoot, state } = command.netlify
const { siteInfo: existingSiteInfo } = command.netlify
Expand All @@ -241,6 +258,10 @@ export const init = async (
// Add .netlify to .gitignore file
await ensureNetlifyIgnore(repositoryRoot)

if (shouldSetupAgentSkills) {
await installAgentSkills(command)
}

const repoUrl = getRepoUrl(existingSiteInfo)
if (repoUrl && !options.force) {
logExistingAndExit({ siteInfo: existingSiteInfo })
Expand Down
Loading
Loading