Rename all four packages/pi-* directories to forge-native names, stripping the 'pi' identity and establishing forge's own: - packages/pi-coding-agent → packages/coding-agent - packages/pi-ai → packages/ai - packages/pi-agent-core → packages/agent-core - packages/pi-tui → packages/tui Package names updated: - @singularity-forge/pi-coding-agent → @singularity-forge/coding-agent - @singularity-forge/pi-ai → @singularity-forge/ai - @singularity-forge/pi-agent-core → @singularity-forge/agent-core - @singularity-forge/pi-tui → @singularity-forge/tui All import references, bare string references, path references, internal variable names (_bundledPi*), and dist files updated. @mariozechner/pi-* third-party compat aliases preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39 lines
1,002 B
TypeScript
39 lines
1,002 B
TypeScript
import type { AuthStorage } from "@singularity-forge/coding-agent";
|
|
|
|
type AnthropicMigrationDeps = {
|
|
authStorage: Pick<AuthStorage, "getCredentialsForProvider">;
|
|
isClaudeCodeReady: boolean;
|
|
defaultProvider: string | undefined;
|
|
env?: NodeJS.ProcessEnv;
|
|
};
|
|
|
|
export function hasDirectAnthropicApiKey(
|
|
authStorage: Pick<AuthStorage, "getCredentialsForProvider">,
|
|
env: NodeJS.ProcessEnv = process.env,
|
|
): boolean {
|
|
if ((env.ANTHROPIC_API_KEY ?? "").trim()) {
|
|
return true;
|
|
}
|
|
|
|
return authStorage
|
|
.getCredentialsForProvider("anthropic")
|
|
.some(
|
|
(credential: any) =>
|
|
credential?.type === "api_key" &&
|
|
typeof credential?.key === "string" &&
|
|
credential.key.trim().length > 0,
|
|
);
|
|
}
|
|
|
|
export function shouldMigrateAnthropicToClaudeCode({
|
|
authStorage,
|
|
isClaudeCodeReady,
|
|
defaultProvider,
|
|
env = process.env,
|
|
}: AnthropicMigrationDeps): boolean {
|
|
if (!isClaudeCodeReady || defaultProvider !== "anthropic") {
|
|
return false;
|
|
}
|
|
|
|
return !hasDirectAnthropicApiKey(authStorage, env);
|
|
}
|