Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions crates/forge_api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ pub trait API: Sync + Send {
/// Initialize a new empty workspace
async fn init_workspace(&self, path: PathBuf) -> Result<forge_domain::WorkspaceId>;

/// Migrate environment variable-based credentials to file-based
/// credentials. This is a one-time migration that runs only if the
/// credentials file doesn't exist.
async fn migrate_env_credentials(&self) -> Result<Option<forge_domain::MigrationResult>>;

async fn generate_data(
&self,
data_parameters: DataGenerationParameters,
Expand Down
4 changes: 0 additions & 4 deletions crates/forge_api/src/forge_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,6 @@ impl<A: Services, F: CommandInfra + EnvironmentInfra + SkillRepository + GrpcInf
self.services.init_workspace(path).await
}

async fn migrate_env_credentials(&self) -> Result<Option<forge_domain::MigrationResult>> {
Ok(self.services.migrate_env_credentials().await?)
}

async fn generate_data(
&self,
data_parameters: DataGenerationParameters,
Expand Down
4 changes: 0 additions & 4 deletions crates/forge_app/src/command_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,6 @@ mod tests {
async fn remove_credential(&self, _id: &ProviderId) -> Result<()> {
Ok(())
}

async fn migrate_env_credentials(&self) -> anyhow::Result<Option<MigrationResult>> {
Ok(None)
}
}

#[async_trait::async_trait]
Expand Down
12 changes: 0 additions & 12 deletions crates/forge_app/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ pub trait ProviderService: Send + Sync {
credential: forge_domain::AuthCredential,
) -> anyhow::Result<()>;
async fn remove_credential(&self, id: &forge_domain::ProviderId) -> anyhow::Result<()>;
/// Migrates environment variable-based credentials to file-based
/// credentials. Returns Some(MigrationResult) if credentials were migrated,
/// None if file already exists or no credentials to migrate.
async fn migrate_env_credentials(
&self,
) -> anyhow::Result<Option<forge_domain::MigrationResult>>;
}

/// Manages user preferences for default providers and models.
Expand Down Expand Up @@ -672,12 +666,6 @@ impl<I: Services> ProviderService for I {
async fn remove_credential(&self, id: &forge_domain::ProviderId) -> anyhow::Result<()> {
self.provider_service().remove_credential(id).await
}

async fn migrate_env_credentials(
&self,
) -> anyhow::Result<Option<forge_domain::MigrationResult>> {
self.provider_service().migrate_env_credentials().await
}
}

#[async_trait::async_trait]
Expand Down
2 changes: 0 additions & 2 deletions crates/forge_domain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mod mcp_servers;
mod merge;
mod message;
mod message_pattern;
mod migration;
mod model;
mod node;
mod point;
Expand Down Expand Up @@ -82,7 +81,6 @@ pub use mcp::*;
pub use mcp_servers::*;
pub use message::*;
pub use message_pattern::*;
pub use migration::*;
pub use model::*;
pub use node::*;
pub use point::*;
Expand Down
41 changes: 0 additions & 41 deletions crates/forge_domain/src/migration.rs

This file was deleted.

5 changes: 2 additions & 3 deletions crates/forge_domain/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use url::Url;

use crate::{
AnyProvider, AuthCredential, ChatCompletionMessage, Context, Conversation, ConversationId,
MigrationResult, Model, ModelId, Provider, ProviderId, ProviderTemplate, ResultStream,
SearchMatch, Skill, Snapshot, WorkspaceAuth, WorkspaceId,
Model, ModelId, Provider, ProviderId, ProviderTemplate, ResultStream, SearchMatch, Skill,
Snapshot, WorkspaceAuth, WorkspaceId,
};

/// Repository for managing file snapshots
Expand Down Expand Up @@ -107,7 +107,6 @@ pub trait ProviderRepository: Send + Sync {
async fn upsert_credential(&self, credential: AuthCredential) -> anyhow::Result<()>;
async fn get_credential(&self, id: &ProviderId) -> anyhow::Result<Option<AuthCredential>>;
async fn remove_credential(&self, id: &ProviderId) -> anyhow::Result<()>;
async fn migrate_env_credentials(&self) -> anyhow::Result<Option<MigrationResult>>;
}

/// Repository for managing workspace indexing and search operations
Expand Down
27 changes: 0 additions & 27 deletions crates/forge_main/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2910,8 +2910,6 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {

/// Initialize the state of the UI
async fn init_state(&mut self, first: bool) -> Result<()> {
let _ = self.handle_migrate_credentials().await;

// Ensure we have a model selected before proceeding with initialization
let active_agent = self.api.get_active_agent().await;

Expand Down Expand Up @@ -4079,31 +4077,6 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
Ok(())
}

/// Handle credential migration
async fn handle_migrate_credentials(&mut self) -> Result<()> {
// Perform the migration
self.spinner.start(Some("Migrating credentials"))?;
let result = self.api.migrate_env_credentials().await?;
self.spinner.stop(None)?;

// Display results based on whether migration occurred
if let Some(result) = result {
self.writeln_title(
TitleFormat::warning("Forge no longer reads API keys from environment variables.")
.sub_title("Learn more: https://forgecode.dev/docs/custom-providers/"),
)?;

let count = result.migrated_providers.len();
let message = if count == 1 {
"Migrated 1 provider from environment variables".to_string()
} else {
format!("Migrated {count} providers from environment variables")
};
self.writeln_title(TitleFormat::info(message))?;
}
Ok(())
}

/// Silently install VS Code extension if in VS Code and extension not
/// installed.
/// NOTE: This is a non-cancellable and a slow task. We should only run this
Expand Down
6 changes: 1 addition & 5 deletions crates/forge_repo/src/forge_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use forge_app::{
use forge_domain::{
AnyProvider, AuthCredential, ChatCompletionMessage, ChatRepository, CommandOutput, Context,
Conversation, ConversationId, ConversationRepository, Environment, FileInfo,
FuzzySearchRepository, McpServerConfig, MigrationResult, Model, ModelId, Provider, ProviderId,
FuzzySearchRepository, McpServerConfig, Model, ModelId, Provider, ProviderId,
ProviderRepository, ResultStream, SearchMatch, Skill, SkillRepository, Snapshot,
SnapshotRepository,
};
Expand Down Expand Up @@ -182,10 +182,6 @@ impl<F: EnvironmentInfra + FileReaderInfra + FileWriterInfra + HttpInfra + Send
// All providers now use file-based credentials
self.provider_repository.remove_credential(id).await
}

async fn migrate_env_credentials(&self) -> anyhow::Result<Option<MigrationResult>> {
self.provider_repository.migrate_env_to_file().await
}
}

#[async_trait::async_trait]
Expand Down
Loading
Loading