Skip to content

Commit 568a35b

Browse files
fix(cli): ag init --force implies --yes, --yes creates config on partial state (#3345, #3354) (#3391)
#3354: --force now implies --yes (non-interactive). Previously, --force still prompted for 4 interactive questions. The docs say --force skips the confirmation prompt, which now matches behavior. #3345: --yes with partial state (no config.yaml but .aegis/ exists with other files like keys.json) now correctly creates config.yaml instead of silently skipping and claiming success. Fixes: #3345, #3354
1 parent 8dd5515 commit 568a35b

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

src/commands/init.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,10 @@ export async function handleInit(args: string[], io: CliIO): Promise<number> {
562562

563563
// --- Config bootstrap path ---
564564

565-
const yes = args.includes('--yes') || args.includes('-y');
565+
let yes = args.includes('--yes') || args.includes('-y');
566566
const force = args.includes("--force") || args.includes("-f");
567+
// #3354: --force implies --yes (non-interactive) — docs say "skip confirmation prompt"
568+
if (force) yes = true;
567569
const flagModel = getOptionValue(args, '--model');
568570
const flagName = getOptionValue(args, '--name');
569571
const configPath = resolveInitConfigPath(args);
@@ -668,18 +670,22 @@ export async function handleInit(args: string[], io: CliIO): Promise<number> {
668670

669671
if (existingConfigText !== null && needsWrite) {
670672
if (yes && !force) {
671-
writeLine(io.stdout, ` ℹ️ Left ${displayConfigPath} unchanged because --yes never overwrites (use --force to override) existing files.`);
672-
printInitSummary(io, {
673-
authToken: existingToken,
674-
baseUrl: existingConfig?.baseUrl ? normalizeBaseUrl(existingConfig.baseUrl) : baseUrl,
675-
commandPrefix,
676-
configPath: displayConfigPath,
677-
dashboardEnabled: existingConfig?.dashboardEnabled ?? dashboardEnabled,
678-
tokenCreated: false,
679-
identityScaffolded: false,
680-
wroteConfig: false,
681-
});
682-
return 0;
673+
// #3345: Only skip write when there's an actual existing config to preserve.
674+
// When config file doesn't exist (partial state), --yes should still create it.
675+
if (existingConfig) {
676+
writeLine(io.stdout, ` ℹ️ Left ${displayConfigPath} unchanged because --yes never overwrites (use --force to override) existing files.`);
677+
printInitSummary(io, {
678+
authToken: existingToken,
679+
baseUrl: existingConfig?.baseUrl ? normalizeBaseUrl(existingConfig.baseUrl) : baseUrl,
680+
commandPrefix,
681+
configPath: displayConfigPath,
682+
dashboardEnabled: existingConfig?.dashboardEnabled ?? dashboardEnabled,
683+
tokenCreated: false,
684+
identityScaffolded: false,
685+
wroteConfig: false,
686+
});
687+
return 0;
688+
}
683689
}
684690

685691
// Issue #3351: --yes --force should auto-overwrite without prompting

0 commit comments

Comments
 (0)