feat: allow ramble codex and gemini providers

This commit is contained in:
rob 2025-11-02 00:46:36 -03:00
parent 05959e6884
commit 870308f9f6
1 changed files with 10 additions and 24 deletions

View File

@ -718,11 +718,7 @@ def load_ramble_preferences(repo_root: Path) -> Tuple[List[str], str, Dict[str,
if default_provider not in provider_choices:
default_provider = "mock"
claude_defaults = provider_map.get("claude", {})
if not isinstance(claude_defaults, dict):
claude_defaults = {}
return provider_choices, default_provider, claude_defaults, provider_map
return provider_choices, default_provider, provider_map
def build_provider(name: str, args: "argparse.Namespace", providers: Dict[str, Dict[str, Any]]) -> RambleProvider:
@ -737,19 +733,18 @@ def build_provider(name: str, args: "argparse.Namespace", providers: Dict[str, D
if kind == "mock":
return cast(RambleProvider, MockProvider())
if kind in {"claude", "claude_cli"}:
cmd = args.claude_cmd or meta.get("command") or "claude"
if kind in {"claude", "claude_cli", "codex", "codex_cli", "gemini", "gemini_cli"}:
cmd = meta.get("command") or name
extra_args = meta.get("args", []) or []
if isinstance(extra_args, str):
extra_args = [extra_args]
extra_args = [str(x) for x in extra_args]
use_arg_p = bool(meta.get("use_arg_p", True))
log_path = str(meta.get("log_path", "/tmp/ramble_claude.log"))
timeout_s = int(args.timeout)
tail_chars = int(args.tail)
debug_flag = bool(args.debug or meta.get("debug", False))
provider_kind = kind.split("_")[0]
return cast(
RambleProvider,
ClaudeCLIProvider(
@ -757,9 +752,9 @@ def build_provider(name: str, args: "argparse.Namespace", providers: Dict[str, D
extra_args=extra_args,
timeout_s=timeout_s,
tail_chars=tail_chars,
use_arg_p=use_arg_p,
use_arg_p=True,
debug=debug_flag,
log_path=log_path,
log_path=str(meta.get("log_path", "/tmp/ramble_ai.log")),
),
)
@ -769,22 +764,13 @@ def build_provider(name: str, args: "argparse.Namespace", providers: Dict[str, D
def parse_args(
provider_choices: List[str],
default_provider: str,
claude_defaults: Dict[str, Any],
):
p = argparse.ArgumentParser(description="Ramble → Generate (PlantUML + optional images)")
p.add_argument("--provider", choices=provider_choices, default=default_provider)
claude_cmd_default = str(claude_defaults.get("command", "claude"))
try:
timeout_default = int(claude_defaults.get("timeout_s", 90))
except (TypeError, ValueError):
timeout_default = 90
try:
tail_default = int(claude_defaults.get("tail_chars", 6000))
except (TypeError, ValueError):
tail_default = 6000
timeout_default = 90
tail_default = 6000
p.add_argument("--claude-cmd", default=claude_cmd_default, help="Path to claude CLI")
p.add_argument("--stability", action="store_true", help="Enable Stability AI images (needs STABILITY_API_KEY)")
p.add_argument("--pexels", action="store_true", help="Enable Pexels images (needs PEXELS_API_KEY); ignored if --stability set")
p.add_argument("--prompt", default="Explain your new feature idea")
@ -798,8 +784,8 @@ def parse_args(
if __name__ == "__main__":
repo_root = Path.cwd()
provider_choices, default_provider, claude_defaults, provider_map = load_ramble_preferences(repo_root)
args = parse_args(provider_choices, default_provider, claude_defaults)
provider_choices, default_provider, provider_map = load_ramble_preferences(repo_root)
args = parse_args(provider_choices, default_provider)
# Provider selection with fallback
try: