Skip to content

Commit 3608288

Browse files
zerone0xclaude
andcommitted
fix(cli): auto-detect existing agent files in migration without modifying selectAgentTargetPaths
Revert changes to selectAgentTargetPaths and instead apply the same auto-detection pattern already used in create/bin.ts to migration/bin.ts. This skips the agent selector prompt when agent files exist, while preserving the full conflict resolution and content update flow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e6f21a9 commit 3608288

2 files changed

Lines changed: 14 additions & 17 deletions

File tree

packages/cli/src/migration/bin.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '../types/index.js';
1515
import {
1616
detectAgentConflicts,
17+
detectExistingAgentTargetPaths,
1718
selectAgentTargetPaths,
1819
writeAgentInstructions,
1920
} from '../utils/agent.js';
@@ -339,13 +340,19 @@ async function collectMigrationPlan(
339340
}
340341
}
341342

342-
// 3. Agent selection
343-
const selectedAgentTargetPaths = await selectAgentTargetPaths({
344-
interactive: options.interactive,
345-
agent: options.agent,
346-
projectRoot: rootDir,
347-
onCancel: () => cancelAndExit(),
348-
});
343+
// 3. Agent selection (auto-detect existing agent files to skip the selector prompt)
344+
const existingAgentTargetPaths =
345+
options.agent !== undefined || !options.interactive
346+
? undefined
347+
: detectExistingAgentTargetPaths(rootDir);
348+
const selectedAgentTargetPaths =
349+
existingAgentTargetPaths !== undefined
350+
? existingAgentTargetPaths
351+
: await selectAgentTargetPaths({
352+
interactive: options.interactive,
353+
agent: options.agent,
354+
onCancel: () => cancelAndExit(),
355+
});
349356

350357
// 4. Agent conflict detection + prompting
351358
const agentConflicts = await detectAgentConflicts({

packages/cli/src/utils/agent.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,27 +196,17 @@ const AGENT_INSTRUCTIONS_END_MARKER = '<!--VITE PLUS END-->';
196196
export async function selectAgentTargetPaths({
197197
interactive,
198198
agent,
199-
projectRoot,
200199
onCancel,
201200
}: {
202201
interactive: boolean;
203202
agent?: AgentSelection;
204-
projectRoot?: string;
205203
onCancel: () => void;
206204
}) {
207205
// Skip entirely if --no-agent is passed
208206
if (agent === false) {
209207
return undefined;
210208
}
211209

212-
// If agent files already exist in the project, reuse them instead of prompting
213-
if (interactive && !agent && projectRoot) {
214-
const existingPaths = detectExistingAgentTargetPaths(projectRoot);
215-
if (existingPaths) {
216-
return existingPaths;
217-
}
218-
}
219-
220210
if (interactive && !agent) {
221211
const selectedAgents = await prompts.multiselect({
222212
message: 'Which agents are you using?',

0 commit comments

Comments
 (0)