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 @@ -23,6 +23,7 @@ netlify init
- `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
- `reset-context` (*boolean*) - Replace locally edited Netlify skills with the latest release, and migrate or delete edited copies under renamed or deprecated names
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

Expand Down
9 changes: 8 additions & 1 deletion src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ 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')
.option(
'--reset-context',
'Replace locally edited Netlify skills with the latest release, and migrate or delete edited copies under renamed or deprecated names',
)
.addHelpText('after', () => {
const docsUrl = 'https://docs.netlify.com/cli/get-started/'
return `
Expand All @@ -20,5 +24,8 @@ 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, { setupAgentSkills: !options.skipAgentSetup })
await init(options, command, {
setupAgentSkills: !options.skipAgentSetup,
resetContext: Boolean(options.resetContext),
})
})
16 changes: 12 additions & 4 deletions src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,17 @@ type InitExtraOptions = {
customizeExitMessage?: InitExitMessageCustomizer | undefined
exitAfterConfiguringRepo?: boolean | undefined
setupAgentSkills?: boolean | undefined
resetContext?: boolean | undefined
}

const installAgentSkills = async (command: BaseCommand): Promise<void> => {
const installAgentSkills = async (command: BaseCommand, reset: boolean): Promise<void> => {
log()
const result = await setupAgentSkills({ workingDir: command.netlify.repositoryRoot })
const result = await setupAgentSkills({ workingDir: command.netlify.repositoryRoot, reset })
await track('sites_agentSkillsSetup', {
installed: result.installed,
directories: result.directories,
skillsVersion: result.skillsVersion,
resetContext: reset,
...result.summary,
})
}
Expand All @@ -245,9 +247,15 @@ export const init = async (
customizeExitMessage,
exitAfterConfiguringRepo = false,
setupAgentSkills: shouldSetupAgentSkills = false,
resetContext = false,
}: InitExtraOptions = {},
): Promise<SiteInfo> => {
command.setAnalyticsPayload({ manual: options.manual, force: options.force, skipAgentSetup: options.skipAgentSetup })
command.setAnalyticsPayload({
manual: options.manual,
force: options.force,
skipAgentSetup: options.skipAgentSetup,
resetContext: options.resetContext,
})

const { repositoryRoot, state } = command.netlify
const { siteInfo: existingSiteInfo } = command.netlify
Expand All @@ -259,7 +267,7 @@ export const init = async (
await ensureNetlifyIgnore(repositoryRoot)

if (shouldSetupAgentSkills) {
await installAgentSkills(command)
await installAgentSkills(command, resetContext)
}

const repoUrl = getRepoUrl(existingSiteInfo)
Expand Down
Loading
Loading