From 4d5b584e39cf90a4afaab8af46be2f69dcd914b6 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 19 Nov 2026 11:30:47 +0100 Subject: 0.12.0: provider is a type + URL, plus a config file - --provider opencode|openai-compatible; opencode keeps the session header, openai-compatible needs a base URL and sends none - config file at ~/.config/agent686/config.toml (provider, url, model, flags) - fix the doubled-dash --provider help message --- src/main.rs | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 8f53d9e..a591c07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,8 +38,9 @@ OPTIONS: --show [ID] print a transcript (most recent if no ID) and exit --doctor check key, directories, provider and model, then exit --yolo approve every tool call without asking - --provider preset: opencode-go, openai, openrouter, ollama, - llamacpp, vllm + --provider opencode (requires the session header, default) or + openai-compatible (any OpenAI-style endpoint; pair with + --base-url, e.g. Ollama http://localhost:11434/v1) --lenient tolerate providers that omit [DONE]/usage --system-ca verify TLS with the system trust store -V, --version print the version and exit @@ -201,7 +202,9 @@ fn take_value(iter: &mut impl Iterator, flag: &str) -> Result Err(format!("{flag} needs a value (use --{flag}=… for a value starting with -)")), + _ => Err(format!( + "{flag} needs a value (use {flag}=… for a value starting with -)" + )), } } @@ -233,28 +236,23 @@ fn run(args: Args) { return; } + let cli = agent686::config::Cli { + model: args.model.clone(), + base_url: args.base_url.clone(), + provider: args.provider.clone(), + yolo: args.yolo, + lenient: args.lenient, + system_ca: args.system_ca, + }; + if args.doctor { - let mut config = Config::resolve_lenient( - args.model, - args.base_url, - args.yolo, - args.provider, - args.lenient, - args.system_ca, - ); + let mut config = Config::resolve_lenient(&cli); // `/models` needs the session header too, even though this is not a turn. config.session = session::new_id(); std::process::exit(doctor::run(&config, args.json)); } - let mut cfg = match Config::resolve( - args.model, - args.base_url, - args.yolo, - args.provider, - args.lenient, - args.system_ca, - ) { + let mut cfg = match Config::resolve(&cli) { Ok(cfg) => cfg, Err(message) => { eprintln!("agent686: {message}"); @@ -708,7 +706,7 @@ fn ago(modified: SystemTime) -> String { /// `--yolo` with no approval and no undo is how a transcript ends up deleting a /// checkout. Git is the documented undo, so `--yolo` needs a repository unless -/// asked twice. `$HOME` and `/` are refused outright. +/// allowed. `$HOME` and `/` are refused outright. fn refuse_yolo(cfg: &Config) { if !cfg.yolo { return; @@ -720,19 +718,19 @@ fn refuse_yolo(cfg: &Config) { let home = std::env::var_os("HOME").map(PathBuf::from); let at_home = home.as_deref() == Some(cwd.as_path()); let at_root = cwd.parent().is_none(); - if (at_home || at_root) && std::env::var_os("AGENT686_ALLOW_HOME").is_none() { + if (at_home || at_root) && !cfg.allow_home { eprintln!( "agent686: refusing --yolo in {} — the model can overwrite anything here. \ - Run inside a project, or set AGENT686_ALLOW_HOME=1.", + Run inside a project, or set allow_home in the config.", cwd.display() ); std::process::exit(2); } - if !in_git_repo(&cwd) && std::env::var_os("AGENT686_ALLOW_NOGIT").is_none() { + if !in_git_repo(&cwd) && !cfg.allow_nogit { eprintln!( "agent686: refusing --yolo outside a git repository ({} has no .git), so \ - there is no undo. Run git init, or set AGENT686_ALLOW_NOGIT=1.", + there is no undo. Run git init, or set allow_nogit in the config.", cwd.display() ); std::process::exit(2); -- cgit v1.2.3