Skip to content

Commit 873c63a

Browse files
committed
✨ Add project configuration command
Add ability to create and manage project-specific configs This change adds a new `project-config` command that allows teams to share common settings via version control without exposing API keys: - Create .irisconfig files in repository root with shared settings - Automatically merge project and personal configs at runtime - Implement security measures to prevent API keys in project configs - Add CLI options for managing model, token limits, and parameters - Include comprehensive tests for config security and merging - Refactor config handling for better code organization Project configs enable teams to standardize on models and settings while keeping personal API keys private.
1 parent 46e4ad6 commit 873c63a

6 files changed

Lines changed: 650 additions & 58 deletions

File tree

src/changes/changelog.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ impl ChangelogGenerator {
140140

141141
if version_line.contains("## [") && version_line.contains(']') {
142142
// Insert the date right after the closing bracket
143-
let bracket_pos = version_line.rfind(']')
143+
let bracket_pos = version_line
144+
.rfind(']')
144145
.expect("Failed to find closing bracket in version line");
145146
version_content = format!(
146147
"{} - {}{}",
@@ -173,9 +174,7 @@ impl ChangelogGenerator {
173174
// Combine header with new version content and existing versions
174175
if parts.len() > 1 {
175176
let existing_versions = parts[1..].join("## [");
176-
format!(
177-
"{header}{version_content_with_separator}## [{existing_versions}"
178-
)
177+
format!("{header}{version_content_with_separator}## [{existing_versions}")
179178
} else {
180179
format!("{header}{version_content_with_separator}")
181180
}

src/cli.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,35 @@ pub enum Commands {
216216
param: Option<Vec<String>>,
217217
},
218218

219+
/// Create or update a project-specific configuration file
220+
#[command(
221+
about = "Manage project-specific configuration",
222+
long_about = "Create or update a project-specific .irisconfig file in the repository root."
223+
)]
224+
ProjectConfig {
225+
#[command(flatten)]
226+
common: CommonParams,
227+
228+
/// Set model for the specified provider
229+
#[arg(long, help = "Set model for the specified provider")]
230+
model: Option<String>,
231+
232+
/// Set token limit for the specified provider
233+
#[arg(long, help = "Set token limit for the specified provider")]
234+
token_limit: Option<usize>,
235+
236+
/// Set additional parameters for the specified provider
237+
#[arg(
238+
long,
239+
help = "Set additional parameters for the specified provider (key=value)"
240+
)]
241+
param: Option<Vec<String>>,
242+
243+
/// Print the current project configuration
244+
#[arg(short, long, help = "Print the current project configuration")]
245+
print: bool,
246+
},
247+
219248
/// List available instruction presets
220249
#[command(about = "List available instruction presets")]
221250
ListPresets,
@@ -317,7 +346,7 @@ async fn handle_gen(
317346

318347
/// Handle the `Config` command
319348
fn handle_config(
320-
common: CommonParams,
349+
common: &CommonParams,
321350
api_key: Option<String>,
322351
model: Option<String>,
323352
token_limit: Option<usize>,
@@ -436,7 +465,7 @@ pub async fn handle_command(
436465
token_limit,
437466
param,
438467
} => {
439-
handle_config(common, api_key, model, token_limit, param)?;
468+
handle_config(&common, api_key, model, token_limit, param)?;
440469
}
441470
Commands::ListPresets => {
442471
log_debug!("Handling 'list_presets' command");
@@ -470,6 +499,15 @@ pub async fn handle_command(
470499
} => {
471500
handle_serve(dev, transport, port, listen_address).await?;
472501
}
502+
Commands::ProjectConfig {
503+
common,
504+
model,
505+
token_limit,
506+
param,
507+
print,
508+
} => {
509+
commands::handle_project_config_command(&common, model, token_limit, param, print)?;
510+
}
473511
}
474512

475513
Ok(())

0 commit comments

Comments
 (0)