Skip to content
Merged
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: 3 additions & 2 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::process::ExitCode;

use crate::architect::{self, Reviewed};
use crate::config::{self, UserConfig};
use crate::config::UserConfig;
use crate::failed_run::FailedRun;
use crate::harness::Choice;
use crate::interrupt;
Expand All @@ -25,6 +25,7 @@ use crate::pickup;
use crate::progress;
use crate::run::Ended;
use crate::run_ending;
use crate::setup;
use crate::skills;

/// How a command that did factory work, or was skipped before any, ended.
Expand Down Expand Up @@ -92,7 +93,7 @@ pub fn start(
about: About,
) -> Result<(UserConfig, Started), ExitCode> {
logs::begin(begin);
let config = config::offer_setup()
let config = setup::offer()
.and_then(|()| UserConfig::load())
.map_err(|error| failure(&error))?;
logs::configured(&config);
Expand Down
422 changes: 51 additions & 371 deletions src/config.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl Catalog {
}

/// The catalog `codex debug models` printed as `json`.
fn parse(json: &str) -> Result<Catalog> {
pub fn parse(json: &str) -> Result<Catalog> {
let parsed: Value = serde_json::from_str(json)
.context("codex debug models printed no JSON catalog of Models")?;
let models = parsed["models"]
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ mod progress;
mod prompt;
#[cfg(test)]
mod prompts_page;
mod questions;
mod ready;
mod resend_key;
mod run;
mod run_ending;
mod session;
mod setup;
mod skills;
mod spec_run;
mod update;
Expand Down Expand Up @@ -362,7 +362,7 @@ fn main() -> ExitCode {
return ExitCode::SUCCESS;
}
Ok(Command::Update) => return outcome(update::update()),
Ok(Command::Setup) => return outcome(config::setup()),
Ok(Command::Setup) => return outcome(setup::setup()),
Ok(Command::EmailTest(to)) => {
return outcome(
UserConfig::load().and_then(|config| email::send_test(to, &config.email)),
Expand Down
24 changes: 23 additions & 1 deletion src/resend_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct ResendKey {
}

/// Where a Resend API key came from.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Source {
/// The `RESEND_API_KEY` environment variable.
Environment,
Expand Down Expand Up @@ -284,6 +284,28 @@ mod tests {
}
}

#[test]
fn a_saved_key_is_replaced_in_place_keeping_the_rest_of_the_credentials() {
let saved = "# My secrets.\n[resend]\n# Rotated monthly.\nkey = \"re_saved_456\" # from the dashboard\n";

assert_eq!(
with_key(saved, "re_secret_123").unwrap(),
"# My secrets.\n[resend]\n# Rotated monthly.\nkey = \"re_secret_123\" # from the dashboard\n"
);
}

#[test]
fn a_key_is_added_after_credentials_that_hold_none() {
let text = with_key("# Keys go here.\n", "re_secret_123").unwrap();

assert!(text.starts_with("# Keys go here.\n"), "{text}");
let file = Source::Credentials(PathBuf::from("/home/me/.thirdshift/credentials.toml"));
assert_eq!(
parse(&text, &file).unwrap().as_deref(),
Some("re_secret_123")
);
}

#[test]
fn broken_credentials_are_an_error_naming_the_file_and_what_is_wrong() {
let path = "/home/me/.thirdshift/credentials.toml";
Expand Down
Loading
Loading