From e6f21a9535ef3c4df529d1f332ef64ce13d04ef0 Mon Sep 17 00:00:00 2001 From: zerone0x Date: Mon, 16 Mar 2026 11:31:59 +0800 Subject: [PATCH 1/2] fix(cli): skip agent selector when AGENTS.md already exists When running `vp migrate`, detect existing agent instruction files (AGENTS.md, CLAUDE.md, etc.) in the project root and reuse them instead of showing the interactive agent selector prompt. Fixes #903 Co-Authored-By: Claude Opus 4.6 --- packages/cli/src/migration/bin.ts | 1 + packages/cli/src/utils/agent.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/cli/src/migration/bin.ts b/packages/cli/src/migration/bin.ts index 3f807f7d16..4d739c3230 100644 --- a/packages/cli/src/migration/bin.ts +++ b/packages/cli/src/migration/bin.ts @@ -343,6 +343,7 @@ async function collectMigrationPlan( const selectedAgentTargetPaths = await selectAgentTargetPaths({ interactive: options.interactive, agent: options.agent, + projectRoot: rootDir, onCancel: () => cancelAndExit(), }); diff --git a/packages/cli/src/utils/agent.ts b/packages/cli/src/utils/agent.ts index a4a38c1b36..34e8264a12 100644 --- a/packages/cli/src/utils/agent.ts +++ b/packages/cli/src/utils/agent.ts @@ -196,10 +196,12 @@ const AGENT_INSTRUCTIONS_END_MARKER = ''; export async function selectAgentTargetPaths({ interactive, agent, + projectRoot, onCancel, }: { interactive: boolean; agent?: AgentSelection; + projectRoot?: string; onCancel: () => void; }) { // Skip entirely if --no-agent is passed @@ -207,6 +209,14 @@ export async function selectAgentTargetPaths({ return undefined; } + // If agent files already exist in the project, reuse them instead of prompting + if (interactive && !agent && projectRoot) { + const existingPaths = detectExistingAgentTargetPaths(projectRoot); + if (existingPaths) { + return existingPaths; + } + } + if (interactive && !agent) { const selectedAgents = await prompts.multiselect({ message: 'Which agents are you using?', From 3608288146ed549b5324a398077e97f9ef6f63d7 Mon Sep 17 00:00:00 2001 From: zerone0x Date: Mon, 16 Mar 2026 12:26:41 +0800 Subject: [PATCH 2/2] 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 --- packages/cli/src/migration/bin.ts | 21 ++++++++++++++------- packages/cli/src/utils/agent.ts | 10 ---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/cli/src/migration/bin.ts b/packages/cli/src/migration/bin.ts index 4d739c3230..8606445634 100644 --- a/packages/cli/src/migration/bin.ts +++ b/packages/cli/src/migration/bin.ts @@ -14,6 +14,7 @@ import { } from '../types/index.js'; import { detectAgentConflicts, + detectExistingAgentTargetPaths, selectAgentTargetPaths, writeAgentInstructions, } from '../utils/agent.js'; @@ -339,13 +340,19 @@ async function collectMigrationPlan( } } - // 3. Agent selection - const selectedAgentTargetPaths = await selectAgentTargetPaths({ - interactive: options.interactive, - agent: options.agent, - projectRoot: rootDir, - onCancel: () => cancelAndExit(), - }); + // 3. Agent selection (auto-detect existing agent files to skip the selector prompt) + const existingAgentTargetPaths = + options.agent !== undefined || !options.interactive + ? undefined + : detectExistingAgentTargetPaths(rootDir); + const selectedAgentTargetPaths = + existingAgentTargetPaths !== undefined + ? existingAgentTargetPaths + : await selectAgentTargetPaths({ + interactive: options.interactive, + agent: options.agent, + onCancel: () => cancelAndExit(), + }); // 4. Agent conflict detection + prompting const agentConflicts = await detectAgentConflicts({ diff --git a/packages/cli/src/utils/agent.ts b/packages/cli/src/utils/agent.ts index 34e8264a12..a4a38c1b36 100644 --- a/packages/cli/src/utils/agent.ts +++ b/packages/cli/src/utils/agent.ts @@ -196,12 +196,10 @@ const AGENT_INSTRUCTIONS_END_MARKER = ''; export async function selectAgentTargetPaths({ interactive, agent, - projectRoot, onCancel, }: { interactive: boolean; agent?: AgentSelection; - projectRoot?: string; onCancel: () => void; }) { // Skip entirely if --no-agent is passed @@ -209,14 +207,6 @@ export async function selectAgentTargetPaths({ return undefined; } - // If agent files already exist in the project, reuse them instead of prompting - if (interactive && !agent && projectRoot) { - const existingPaths = detectExistingAgentTargetPaths(projectRoot); - if (existingPaths) { - return existingPaths; - } - } - if (interactive && !agent) { const selectedAgents = await prompts.multiselect({ message: 'Which agents are you using?',