From 92d1f04de34096039ec8ed2ce4d006422ecdf3ac Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 19 Jun 2026 18:33:47 +0800 Subject: [PATCH] refactor(agents): drop duplicate internal aliases --- src/agents/auth-profiles.external-cli-sync.test.ts | 8 ++++---- src/agents/auth-profiles/effective-oauth.test.ts | 12 ++++++------ src/agents/auth-profiles/effective-oauth.ts | 4 ++-- src/agents/auth-profiles/external-cli-sync.ts | 2 -- src/agents/auth-profiles/external-oauth.test.ts | 6 +++--- .../auth-profiles/oauth-common-mocks.test-support.ts | 1 - src/agents/auth-profiles/oauth.ts | 4 ++-- src/agents/cli-runner.spawn.test.ts | 6 +++--- src/agents/cli-runner/helpers.ts | 3 --- src/commands/migrate.test.ts | 1 - src/commands/migrate.ts | 6 +++--- src/commands/migrate/skill-selection-prompt.ts | 7 ------- 12 files changed, 23 insertions(+), 37 deletions(-) diff --git a/src/agents/auth-profiles.external-cli-sync.test.ts b/src/agents/auth-profiles.external-cli-sync.test.ts index d3bc86c5f75e..757cdeaa2f84 100644 --- a/src/agents/auth-profiles.external-cli-sync.test.ts +++ b/src/agents/auth-profiles.external-cli-sync.test.ts @@ -15,7 +15,7 @@ const mocks = vi.hoisted(() => ({ readMiniMaxCliCredentialsCached: vi.fn<(options?: unknown) => OAuthCredential | null>(() => null), })); -let readManagedExternalCliCredential: typeof import("./auth-profiles/external-cli-sync.js").readManagedExternalCliCredential; +let readExternalCliBootstrapCredential: typeof import("./auth-profiles/external-cli-sync.js").readExternalCliBootstrapCredential; let resolveExternalCliAuthProfiles: typeof import("./auth-profiles/external-cli-sync.js").resolveExternalCliAuthProfiles; let hasUsableOAuthCredential: typeof import("./auth-profiles/external-cli-sync.js").hasUsableOAuthCredential; let isSafeToUseExternalCliCredential: typeof import("./auth-profiles/external-cli-sync.js").isSafeToUseExternalCliCredential; @@ -121,7 +121,7 @@ describe("external cli oauth resolution", () => { ({ hasUsableOAuthCredential, isSafeToUseExternalCliCredential, - readManagedExternalCliCredential, + readExternalCliBootstrapCredential, resolveExternalCliAuthProfiles, shouldBootstrapFromExternalCliCredential, shouldReplaceStoredOAuthCredential, @@ -299,7 +299,7 @@ describe("external cli oauth resolution", () => { }), ); - const credential = readManagedExternalCliCredential({ + const credential = readExternalCliBootstrapCredential({ profileId: OPENAI_CODEX_DEFAULT_PROFILE_ID, credential: makeOAuthCredential({ provider: "openai" }), }); @@ -365,7 +365,7 @@ describe("external cli oauth resolution", () => { makeOAuthCredential({ provider: "openai" }), ); - const credential = readManagedExternalCliCredential({ + const credential = readExternalCliBootstrapCredential({ profileId: OPENAI_CODEX_DEFAULT_PROFILE_ID, credential: makeOAuthCredential({ provider: "anthropic" }), }); diff --git a/src/agents/auth-profiles/effective-oauth.test.ts b/src/agents/auth-profiles/effective-oauth.test.ts index 9b4c37a736fb..e802f86cfd52 100644 --- a/src/agents/auth-profiles/effective-oauth.test.ts +++ b/src/agents/auth-profiles/effective-oauth.test.ts @@ -8,11 +8,11 @@ import { resolveEffectiveOAuthCredential } from "./effective-oauth.js"; import type { OAuthCredential } from "./types.js"; const mocks = vi.hoisted(() => ({ - readManagedExternalCliCredential: vi.fn<() => OAuthCredential | null>(() => null), + readExternalCliBootstrapCredential: vi.fn<() => OAuthCredential | null>(() => null), })); vi.mock("./external-cli-sync.js", () => ({ - readManagedExternalCliCredential: mocks.readManagedExternalCliCredential, + readExternalCliBootstrapCredential: mocks.readExternalCliBootstrapCredential, })); function makeCredential(overrides: Partial = {}): OAuthCredential { @@ -28,7 +28,7 @@ function makeCredential(overrides: Partial = {}): OAuthCredenti describe("resolveEffectiveOAuthCredential", () => { beforeEach(() => { - mocks.readManagedExternalCliCredential.mockReset().mockReturnValue(null); + mocks.readExternalCliBootstrapCredential.mockReset().mockReturnValue(null); }); it("uses external cli oauth only when local credentials are unusable and safe to bootstrap", () => { @@ -37,7 +37,7 @@ describe("resolveEffectiveOAuthCredential", () => { refresh: "fresh-cli-refresh-token", expires: Date.now() + 30 * 60_000, }); - mocks.readManagedExternalCliCredential.mockReturnValue(imported); + mocks.readExternalCliBootstrapCredential.mockReturnValue(imported); expect( resolveEffectiveOAuthCredential({ @@ -58,7 +58,7 @@ describe("resolveEffectiveOAuthCredential", () => { refresh: "healthy-local-refresh-token", expires: Date.now() + 30 * 60_000, }); - mocks.readManagedExternalCliCredential.mockReturnValue(imported); + mocks.readExternalCliBootstrapCredential.mockReturnValue(imported); expect( resolveEffectiveOAuthCredential({ @@ -75,7 +75,7 @@ describe("resolveEffectiveOAuthCredential", () => { expires: Date.now() + 30 * 60_000, accountId: "acct-external", }); - mocks.readManagedExternalCliCredential.mockReturnValue(imported); + mocks.readExternalCliBootstrapCredential.mockReturnValue(imported); expect( resolveEffectiveOAuthCredential({ diff --git a/src/agents/auth-profiles/effective-oauth.ts b/src/agents/auth-profiles/effective-oauth.ts index ebf33f30c9de..4803a9031a34 100644 --- a/src/agents/auth-profiles/effective-oauth.ts +++ b/src/agents/auth-profiles/effective-oauth.ts @@ -3,7 +3,7 @@ * Delegates to the managed OAuth selector while allowing external CLI * bootstrap credentials to fill unusable local profile state. */ -import { readManagedExternalCliCredential } from "./external-cli-sync.js"; +import { readExternalCliBootstrapCredential } from "./external-cli-sync.js"; import { resolveEffectiveOAuthCredential as resolveManagedOAuthCredential } from "./oauth-manager.js"; import type { OAuthCredential } from "./types.js"; @@ -17,7 +17,7 @@ export function resolveEffectiveOAuthCredential(params: { profileId: params.profileId, credential: params.credential, readBootstrapCredential: ({ profileId, credential }) => - readManagedExternalCliCredential({ + readExternalCliBootstrapCredential({ profileId, credential, allowKeychainPrompt: params.allowKeychainPrompt ?? false, diff --git a/src/agents/auth-profiles/external-cli-sync.ts b/src/agents/auth-profiles/external-cli-sync.ts index 8a605a3cdb88..5353482c6fb8 100644 --- a/src/agents/auth-profiles/external-cli-sync.ts +++ b/src/agents/auth-profiles/external-cli-sync.ts @@ -223,8 +223,6 @@ export function readExternalCliBootstrapCredential(params: { ); } -export const readManagedExternalCliCredential = readExternalCliBootstrapCredential; - /** Read a CLI credential as a fallback for refresh/runtime auth recovery. */ export function readExternalCliFallbackCredential(params: { profileId: string; diff --git a/src/agents/auth-profiles/external-oauth.test.ts b/src/agents/auth-profiles/external-oauth.test.ts index ff729401989a..987d9241a446 100644 --- a/src/agents/auth-profiles/external-oauth.test.ts +++ b/src/agents/auth-profiles/external-oauth.test.ts @@ -1,12 +1,12 @@ /** * Tests runtime external OAuth overlays. * Covers provider plugin profiles, external CLI scoped discovery, persistence - * rules, and compatibility aliases. + * rules, and external CLI bootstrap policy. */ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { ProviderExternalAuthProfile } from "../../plugins/types.js"; import { testing, overlayExternalAuthProfiles } from "./external-auth.js"; -import { readManagedExternalCliCredential } from "./external-cli-sync.js"; +import { readExternalCliBootstrapCredential } from "./external-cli-sync.js"; import type { AuthProfileStore, OAuthCredential } from "./types.js"; const resolveExternalAuthProfilesWithPluginsMock = vi.fn< @@ -186,7 +186,7 @@ describe("auth external oauth helpers", () => { expect(overlaidProfile.access).toBe("fresh-cli-access-token"); expect(overlaidProfile.refresh).toBe("fresh-cli-refresh-token"); expect(overlaidProfile.accountId).toBe("acct-cli"); - const managedCredential = readManagedExternalCliCredential({ + const managedCredential = readExternalCliBootstrapCredential({ profileId: "openai:default", credential: tokenlessCredential, }); diff --git a/src/agents/auth-profiles/oauth-common-mocks.test-support.ts b/src/agents/auth-profiles/oauth-common-mocks.test-support.ts index 4e6ae5ff5eb1..1e37c3004156 100644 --- a/src/agents/auth-profiles/oauth-common-mocks.test-support.ts +++ b/src/agents/auth-profiles/oauth-common-mocks.test-support.ts @@ -46,7 +46,6 @@ vi.mock("./external-cli-sync.js", () => ({ credential.expires - now > 5 * 60 * 1000, isSafeToUseExternalCliCredential: () => true, readExternalCliBootstrapCredential: () => null, - readManagedExternalCliCredential: () => null, resolveExternalCliAuthProfiles: () => [], shouldBootstrapFromExternalCliCredential: () => false, shouldReplaceStoredOAuthCredential: (existing: unknown, incoming: unknown) => diff --git a/src/agents/auth-profiles/oauth.ts b/src/agents/auth-profiles/oauth.ts index 90475c2b4aa7..6c306d088b2e 100644 --- a/src/agents/auth-profiles/oauth.ts +++ b/src/agents/auth-profiles/oauth.ts @@ -26,8 +26,8 @@ import { log } from "./constants.js"; import { resolveTokenExpiryState } from "./credential-state.js"; import { formatAuthDoctorHint } from "./doctor.js"; import { + readExternalCliBootstrapCredential, readExternalCliFallbackCredential, - readManagedExternalCliCredential, } from "./external-cli-sync.js"; import { createOAuthManager, OAuthManagerRefreshError } from "./oauth-manager.js"; import { OAuthRefreshFailureError } from "./oauth-refresh-failure.js"; @@ -232,7 +232,7 @@ const oauthManager = createOAuthManager({ buildApiKey: buildOAuthApiKey, refreshCredential: refreshOAuthCredential, readBootstrapCredential: ({ profileId, credential }) => - readManagedExternalCliCredential({ + readExternalCliBootstrapCredential({ profileId, credential, }), diff --git a/src/agents/cli-runner.spawn.test.ts b/src/agents/cli-runner.spawn.test.ts index e412527344e1..ae2c05423b01 100644 --- a/src/agents/cli-runner.spawn.test.ts +++ b/src/agents/cli-runner.spawn.test.ts @@ -50,7 +50,7 @@ import { executePreparedCliRun, setCliRunnerExecuteTestDeps, } from "./cli-runner/execute.js"; -import { buildSystemPrompt, writeCliSystemPromptFile } from "./cli-runner/helpers.js"; +import { buildCliAgentSystemPrompt, writeCliSystemPromptFile } from "./cli-runner/helpers.js"; import { cliBackendLog, formatCliBackendOutputDigest } from "./cli-runner/log.js"; import { setCliRunnerPrepareTestDeps } from "./cli-runner/prepare.js"; import type { PreparedCliRunContext } from "./cli-runner/types.js"; @@ -391,7 +391,7 @@ describe("runCliAgent spawn path", () => { }); it("includes the OpenClaw skills prompt in CLI system prompts", () => { - const systemPrompt = buildSystemPrompt({ + const systemPrompt = buildCliAgentSystemPrompt({ workspaceDir: "/tmp", modelDisplay: "claude-cli/sonnet", tools: [], @@ -3710,7 +3710,7 @@ ${JSON.stringify({ const { contextFiles } = await realResolveBootstrapContextForRun({ workspaceDir, }); - const allArgs = buildSystemPrompt({ + const allArgs = buildCliAgentSystemPrompt({ workspaceDir, modelDisplay: "claude-cli/sonnet", contextFiles, diff --git a/src/agents/cli-runner/helpers.ts b/src/agents/cli-runner/helpers.ts index 8a99241ab7ff..90e58db60db6 100644 --- a/src/agents/cli-runner/helpers.ts +++ b/src/agents/cli-runner/helpers.ts @@ -197,9 +197,6 @@ export function buildCliAgentSystemPrompt(params: { }); } -/** Alternate export name for the CLI system prompt builder. */ -export const buildSystemPrompt = buildCliAgentSystemPrompt; - /** Applies backend model aliases to a requested CLI model id. */ export function normalizeCliModel(modelId: string, backend: CliBackendConfig): string { const trimmed = modelId.trim(); diff --git a/src/commands/migrate.test.ts b/src/commands/migrate.test.ts index ab5397bc10ea..6a6933e28fd9 100644 --- a/src/commands/migrate.test.ts +++ b/src/commands/migrate.test.ts @@ -56,7 +56,6 @@ vi.mock("@clack/prompts", () => ({ })); vi.mock("./migrate/skill-selection-prompt.js", () => ({ - promptMigrationSelectionValues: mocks.multiselect, promptMigrationSkillSelectionValues: mocks.multiselect, })); diff --git a/src/commands/migrate.ts b/src/commands/migrate.ts index 12f238cce678..7a5acb26256c 100644 --- a/src/commands/migrate.ts +++ b/src/commands/migrate.ts @@ -41,7 +41,7 @@ import { resolveInteractiveMigrationPluginSelection, resolveInteractiveMigrationSkillSelection, } from "./migrate/selection.js"; -import { promptMigrationSelectionValues } from "./migrate/skill-selection-prompt.js"; +import { promptMigrationSkillSelectionValues } from "./migrate/skill-selection-prompt.js"; import type { MigrateApplyOptions, MigrateCommonOptions, @@ -177,7 +177,7 @@ async function promptCodexMigrationSkillSelection( if (skillItems.length === 0) { return plan; } - const selected = await promptMigrationSelectionValues({ + const selected = await promptMigrationSkillSelectionValues({ message: stylePromptMessage("Select Codex skills to migrate into this agent"), options: [ { @@ -238,7 +238,7 @@ async function promptCodexMigrationPluginSelection( if (pluginItems.length === 0) { return plan; } - const selected = await promptMigrationSelectionValues({ + const selected = await promptMigrationSkillSelectionValues({ message: stylePromptMessage("Select native Codex plugins to activate in this agent"), options: [ { diff --git a/src/commands/migrate/skill-selection-prompt.ts b/src/commands/migrate/skill-selection-prompt.ts index 25a2fdf2d839..9602d177f01f 100644 --- a/src/commands/migrate/skill-selection-prompt.ts +++ b/src/commands/migrate/skill-selection-prompt.ts @@ -255,10 +255,3 @@ export function promptMigrationSkillSelectionValues( return prompt.prompt(); } - -/** - * Compatibility alias for plugin selection prompts that share the same picker. - * - * @deprecated Use promptMigrationSkillSelectionValues. - */ -export const promptMigrationSelectionValues = promptMigrationSkillSelectionValues;