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
5 changes: 5 additions & 0 deletions .changeset/intent-no-install-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/create': patch
---

Skip Intent setup when dependency installation is skipped, and print the package-manager-specific follow-up instead of claiming agent guidance was configured.
16 changes: 13 additions & 3 deletions packages/create/src/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { formatCommand } from './utils.js'
import { writeConfigFileToEnvironment } from './config-file.js'
import {
detectPnpmVersion,
getPackageManagerInstallCommand,
getPackageManagerScriptCommand,
intentCommand,
packageManagerInstall,
Expand Down Expand Up @@ -446,9 +447,18 @@ function buildNextSteps(options: Options): string {
sections.push(`Docs for the integrations you picked:\n${docLines.join('\n')}`)
}
if (options.intent) {
sections.push(
`Working with an AI agent? Your agent config (AGENTS.md / CLAUDE.md) was wired up by TanStack Intent\nso your agent can discover skills for the libraries you installed, on demand:\n • ${intentCommand(options.packageManager, ['list'])}\n • ${intentCommand(options.packageManager, ['load', '<package>#<skill>'])}\nTry asking your agent:\n • "migrate this Next.js page to TanStack Start"\n • "add a protected /dashboard route"\n • "show me how to use TanStack Router search params"`,
)
if (options.install === false) {
const installCommand = formatCommand(
getPackageManagerInstallCommand(options.packageManager),
)
sections.push(
`TanStack Intent setup was skipped because dependency installation was skipped.\nInstall dependencies, then generate agent guidance:\n % ${installCommand}\n % ${intentCommand(options.packageManager, ['install', '--map'])}`,
)
} else {
sections.push(
`Working with an AI agent? Your agent config (AGENTS.md / CLAUDE.md) was wired up by TanStack Intent\nso your agent can discover skills for the libraries you installed, on demand:\n • ${intentCommand(options.packageManager, ['list'])}\n • ${intentCommand(options.packageManager, ['load', '<package>#<skill>'])}\nTry asking your agent:\n • "migrate this Next.js page to TanStack Start"\n • "add a protected /dashboard route"\n • "show me how to use TanStack Router search params"`,
)
}
}

return sections.length > 0 ? `\nNext steps:\n\n${sections.join('\n\n')}\n` : ''
Expand Down
29 changes: 26 additions & 3 deletions packages/create/src/edge-create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
INTENT_PACKAGE,
detectPnpmVersion,
getPackageManagerExecuteCommand,
getPackageManagerInstallCommand,
getPackageManagerScriptCommand,
intentCommand,
packageManagerInstall,
Expand Down Expand Up @@ -275,6 +276,19 @@ async function setupIntent(
return
}

if (options.install === false) {
environment.startStep({
id: 'setup-intent',
type: 'info',
message: 'Skipping TanStack Intent setup...',
})
environment.finishStep(
'setup-intent',
'TanStack Intent setup skipped: dependencies not installed',
)
return
}

environment.startStep({
id: 'setup-intent',
type: 'command',
Expand Down Expand Up @@ -565,9 +579,18 @@ function buildNextSteps(options: Options): string {
sections.push(`Docs for the integrations you picked:\n${docLines.join('\n')}`)
}
if (options.intent) {
sections.push(
`Working with an AI agent? Your agent config (AGENTS.md / CLAUDE.md) was wired up by TanStack Intent\nso your agent can discover skills for the libraries you installed, on demand:\n - ${intentCommand(options.packageManager, ['list'])}\n - ${intentCommand(options.packageManager, ['load', '<package>#<skill>'])}\nTry asking your agent:\n - "migrate this Next.js page to TanStack Start"\n - "add a protected /dashboard route"\n - "show me how to use TanStack Router search params"`,
)
if (options.install === false) {
const installCommand = formatCommand(
getPackageManagerInstallCommand(options.packageManager),
)
sections.push(
`TanStack Intent setup was skipped because dependency installation was skipped.\nInstall dependencies, then generate agent guidance:\n % ${installCommand}\n % ${intentCommand(options.packageManager, ['install', '--map'])}`,
)
} else {
sections.push(
`Working with an AI agent? Your agent config (AGENTS.md / CLAUDE.md) was wired up by TanStack Intent\nso your agent can discover skills for the libraries you installed, on demand:\n - ${intentCommand(options.packageManager, ['list'])}\n - ${intentCommand(options.packageManager, ['load', '<package>#<skill>'])}\nTry asking your agent:\n - "migrate this Next.js page to TanStack Start"\n - "add a protected /dashboard route"\n - "show me how to use TanStack Router search params"`,
)
}
}

return sections.length > 0 ? `\nNext steps:\n\n${sections.join('\n\n')}\n` : ''
Expand Down
13 changes: 13 additions & 0 deletions packages/create/src/integrations/intent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ export async function setupIntent(
return
}

if (options.install === false) {
environment.startStep({
id: 'setup-intent',
type: 'info',
message: 'Skipping TanStack Intent setup...',
})
environment.finishStep(
'setup-intent',
'TanStack Intent setup skipped: dependencies not installed',
)
return
}

const s = environment.spinner()
s.start('Setting up TanStack Intent skill discovery...')
environment.startStep({
Expand Down
49 changes: 49 additions & 0 deletions packages/create/tests/create-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
import { resolve } from 'node:path'

import { createApp } from '../src/create-app.js'
import { createApp as createEdgeApp } from '../src/edge-create-app.js'

import { createMemoryEnvironment } from '../src/environment.js'
import type { AddOn, Options } from '../src/types.js'
Expand Down Expand Up @@ -124,6 +125,54 @@ describe('createApp', () => {
})
})

it.each([createApp, createEdgeApp])(
'skips intent setup and reports the follow-up when dependency install is skipped (%#)',
async (create) => {
const { environment, output } = createMemoryEnvironment()
let outro = ''
environment.outro = (message: string) => {
outro = message
}
await create(environment, {
...simpleOptions,
intent: true,
install: false,
})

expect(output.commands).not.toContainEqual({
command: 'pnpm',
args: ['dlx', '@tanstack/intent', 'install'],
})
expect(outro).not.toContain('was wired up by TanStack Intent')
expect(outro).toContain('TanStack Intent setup was skipped')
expect(outro).toContain('pnpm install')
expect(outro).toContain('pnpm dlx @tanstack/intent install --map')
},
)

it.each([createApp, createEdgeApp])(
'sets up intent and reports the agent config when dependencies are installed (%#)',
async (create) => {
const { environment, output } = createMemoryEnvironment()
let outro = ''
environment.outro = (message: string) => {
outro = message
}
await create(environment, {
...simpleOptions,
intent: true,
install: true,
})

expect(output.commands).toContainEqual({
command: 'pnpm',
args: ['dlx', '@tanstack/intent', 'install'],
})
expect(outro).toContain('was wired up by TanStack Intent')
expect(outro).not.toContain('TanStack Intent setup was skipped')
},
)

it('should create an app - with a add-on', async () => {
const { environment, output } = createMemoryEnvironment()
await createApp(environment, {
Expand Down
64 changes: 64 additions & 0 deletions packages/create/tests/integrations/intent.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { describe, expect, it } from 'vitest'
import { createMemoryEnvironment } from '../../src/environment.js'
import { setupIntent } from '../../src/integrations/intent.js'
import type { Options } from '../../src/types.js'

const options: Options = {
projectName: 'test',
targetDir: '/test',
framework: {
id: 'test',
name: 'Test',
description: '',
version: '1.0.0',
basePackageJSON: {},
optionalPackages: {},
supportedModes: {},
getFiles: async () => [],
getFileContents: async () => '',
getDeletedFiles: async () => [],
getAddOns: () => [],
},
mode: 'file-router',
packageManager: 'pnpm',
typescript: true,
tailwind: false,
git: false,
intent: true,
install: true,
chosenAddOns: [],
addOnOptions: {},
}

describe('intent', () => {
it('skips when disabled', async () => {
const { environment, output } = createMemoryEnvironment()
environment.startRun()
await setupIntent(environment, '/test', { ...options, intent: false })
environment.finishRun()
expect(output.commands).toEqual([])
})
it('runs install when dependencies are installed', async () => {
const { environment, output } = createMemoryEnvironment()
environment.startRun()
await setupIntent(environment, '/test', options)
environment.finishRun()
expect(output.commands).toEqual([
{ command: 'pnpm', args: ['dlx', '@tanstack/intent', 'install'] },
])
})
it('skips the command and reports no configured step without dependencies', async () => {
const { environment, output } = createMemoryEnvironment()
const messages: Array<string> = []
environment.finishStep = (_id, message) => {
messages.push(message)
}
environment.startRun()
await setupIntent(environment, '/test', { ...options, install: false })
environment.finishRun()
expect(output.commands).toEqual([])
expect(messages).toEqual([
'TanStack Intent setup skipped: dependencies not installed',
])
})
})
Loading