Skip to content

Commit bae7c72

Browse files
fix(cli): ag run --port now used in generated config.yaml (#3343)
ensureConfig() now accepts an optional port parameter and generates baseUrl with the correct port instead of always defaulting to 9100. Fixes: #3343
1 parent 76233e7 commit bae7c72

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/commands/run.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async function waitForServer(baseUrl: string, authToken: string | undefined, tim
130130
* Issue #3261: Use AuthManager to create a proper key in keys.json,
131131
* not a random token that the server won't recognize.
132132
*/
133-
async function ensureConfig(configPath: string, stateDir: string): Promise<string | undefined> {
133+
async function ensureConfig(configPath: string, stateDir: string, port?: number): Promise<string | undefined> {
134134
const existing = await readConfigFile(configPath);
135135
if (existing) {
136136
return existing.authToken || existing.clientAuthToken || undefined;
@@ -146,7 +146,7 @@ async function ensureConfig(configPath: string, stateDir: string): Promise<strin
146146

147147
const config: Partial<Config> = {
148148
authToken: token,
149-
baseUrl: 'http://127.0.0.1:9100',
149+
baseUrl: port ? `http://127.0.0.1:${port}` : 'http://127.0.0.1:9100',
150150
dashboardEnabled: true,
151151
acpEnabled: true,
152152
};
@@ -282,7 +282,7 @@ export async function handleRun(args: string[], io: CliIO): Promise<number> {
282282
// Ensure config exists (creates proper key in keys.json via AuthManager)
283283
if (!existingConfig) {
284284
writeLine(io.stdout, ' ⏳ No config found — bootstrapping with defaults...');
285-
const generatedToken = await ensureConfig(configPath, config.stateDir);
285+
const generatedToken = await ensureConfig(configPath, config.stateDir, portOverride ?? undefined);
286286
if (generatedToken) authToken = generatedToken;
287287
writeLine(io.stdout, ` ✅ Config created: ${configPath}`);
288288
}

0 commit comments

Comments
 (0)