From bbce13692f44d65b5d24fbacc0ba419e16df54e9 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Fri, 7 Aug 2026 21:42:30 +0000 Subject: [PATCH] Remove aid: superseded by devlaunch's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aid here reached a repo through renv/rocker, composing and building an image per launch, while devlaunch's dl drives devpod and reuses the workspace it already has for that branch. Both packages installed an aid entry point, so which of the two you got — and whether your container was rebuilt or reused — came down to which was later on PATH. devlaunch 0.0.9 ships an aid with no container machinery of its own: it rewrites its command line into a dl one, so there is a single path to a workspace and nothing left to drift. This one goes: rockerc/aid.py, the entry point, its completion script and its tests. The aid entries in completion.py's legacy tables stay, and they are the point of staying: an rc file written by an earlier rockerc still carries aid's completion block and its `complete` line, so rockerc --install cleans up after the command it no longer installs. A test covers that. rockerc, renv, renvvsc, rockervsc and dp are untouched. Release 0.19.0. --- CHANGELOG.md | 21 ++++ pixi.lock | 18 +-- pyproject.toml | 3 +- rockerc/aid.py | 202 -------------------------------- rockerc/completion.py | 6 +- rockerc/completions/aid.bash | 74 ------------ test/test_aid.py | 165 -------------------------- test/test_completion_install.py | 30 ++++- 8 files changed, 62 insertions(+), 457 deletions(-) delete mode 100644 rockerc/aid.py delete mode 100644 rockerc/completions/aid.bash delete mode 100644 test/test_aid.py diff --git a/CHANGELOG.md b/CHANGELOG.md index b3567df..b5e71f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,27 @@ ## rockerc +## [0.19.0] - 2026-08-07 +### Removed +- `aid`. It is superseded by devlaunch's `aid` (devlaunch 0.0.9), and the two + collided: both packages installed an `aid` entry point, so whichever landed + later on `PATH` won. This `aid` reached a repo through `renv`/rocker, composing + and building an image per launch, where devlaunch's `dl` drives devpod and + reuses the workspace it already has for that branch — the same repo and branch + gave you two different containers depending on which `aid` you got. devlaunch's + `aid` has no container machinery of its own: it rewrites its command line into + a `dl` one, so there is one path to a workspace and nothing to drift. + + Gone with it: `rockerc/aid.py`, the `aid` entry point, its completion script + and its tests. `rockerc --install` still strips a leftover `aid` completion + from `~/.bashrc`, so upgrading cleans up after the old command. + + `rockerc`, `renv`, `renvvsc`, `rockervsc` and `dp` are unaffected. + + Note for anyone who used the flags: devlaunch's `aid` defaults to `--claude` + rather than `--gemini`, and has no equivalent yet for the gemini-only + `-y/--yolo` and `-f/--flash`. + ## [0.13.0] - 2025-09-29 ### Added - Unified always-detached execution model: rocker container is always started (or reused) in detached mode and shell access provided via `docker exec`. diff --git a/pixi.lock b/pixi.lock index 9b96ac9..30eca43 100644 --- a/pixi.lock +++ b/pixi.lock @@ -1180,20 +1180,20 @@ packages: requires_python: '>=3.0' - pypi: ./ name: rockerc - version: 0.18.0 - sha256: 95e535867f0039f15cabf1cd73b8eef6ac5f546c9a64885017d4f10af459a0b5 + version: 0.19.0 + sha256: e06cc51d7d930da31388ff5c9b60bff99a6aaa5afcfc2c16e882c580fea4848a requires_dist: - rocker>=0.2.19 - deps-rocker>=0.23.1 - pyyaml>=5 - iterfzf>=1.0.0 - - pylint>=3.2.5,<=4.0.3 ; extra == 'test' - - pytest-cov>=4.1,<=7.0.0 ; extra == 'test' - - pytest>=7.4,<=9.0.1 ; extra == 'test' - - hypothesis>=6.104.2,<=6.148.3 ; extra == 'test' - - ruff>=0.5.0,<=0.14.7 ; extra == 'test' - - coverage>=7.5.4,<=7.12.0 ; extra == 'test' - - pre-commit<=4.5.0 ; extra == 'test' + - pylint>=3.2.5,<=4.0.5 ; extra == 'test' + - pytest-cov>=4.1,<=7.1.0 ; extra == 'test' + - pytest>=7.4,<=9.0.3 ; extra == 'test' + - hypothesis>=6.104.2,<=6.152.4 ; extra == 'test' + - ruff>=0.5.0,<=0.15.12 ; extra == 'test' + - coverage>=7.5.4,<=7.13.5 ; extra == 'test' + - pre-commit<=4.6.0 ; extra == 'test' - ghrocker==0.0.10 ; extra == 'extensions' - groot-rocker==0.4.1 ; extra == 'extensions' - pypi: https://files.pythonhosted.org/packages/92/05/434ddd86becd64629c25fb6b4ce7637dd52a45cc4a4415a3008fe61c27b9/ruff-0.14.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl diff --git a/pyproject.toml b/pyproject.toml index 6aa3437..a009654 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rockerc" -version = "0.18.0" +version = "0.19.0" authors = [{ name = "Austin Gregg-Smith", email = "blooop@gmail.com" }] description = "A tool to parse rockerc.yaml files and pass on the arguments onto rocker" readme = "README.md" @@ -67,7 +67,6 @@ rockerc = "rockerc.rockerc:run_rockerc" renv = "rockerc.renv:main" renvvsc = "rockerc.renvsc:main" rockervsc = "rockerc.rockervsc:main" -aid = "rockerc.aid:main" dp = "rockerc.dp:main" # Environments diff --git a/rockerc/aid.py b/rockerc/aid.py deleted file mode 100644 index 2d1a50d..0000000 --- a/rockerc/aid.py +++ /dev/null @@ -1,202 +0,0 @@ -""" -aid - AI Develop command for rockerc - -Provides streamlined AI-driven development within containerized environments. -Reuses renv infrastructure for container management and setup. -""" - -import argparse -import logging -import pathlib -import sys -from typing import List, Optional - -from .completion_loader import load_completion_script -from .renv import RepoSpec, manage_container - - -def parse_aid_args(args: Optional[List[str]] = None) -> argparse.Namespace: - """Parse command line arguments for aid command.""" - if args is None: - args = sys.argv[1:] - - parser = argparse.ArgumentParser( - description="AI Develop - Streamlined AI-driven development in containerized environments", - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog=""" -Examples: - aid blooop/my-repo "help me refactor this code" - aid --claude owner/repo@dev "implement a new feature" - aid --gemini owner/repo#subfolder "debug this issue" - """, - ) - - # AI Agent selection (mutually exclusive) - agent_group = parser.add_mutually_exclusive_group() - agent_group.add_argument( - "--gemini", - action="store_const", - dest="agent", - const="gemini", - help="Use Gemini AI (default)", - ) - agent_group.add_argument( - "--claude", action="store_const", dest="agent", const="claude", help="Use Claude AI" - ) - agent_group.add_argument( - "--codex", action="store_const", dest="agent", const="codex", help="Use OpenAI Codex" - ) - - # y/--yolo flag - parser.add_argument( - "-y", - "--yolo", - action="store_true", - help="Pass --yolo to gemini agent", - ) - parser.add_argument( - "-f", - "--flash", - action="store_true", - help="Use Gemini in flash mode (gemini-2.5-flash)", - ) - - # Repository specification - parser.add_argument( - "repo_spec", help="Repository specification: owner/repo[@branch][#subfolder]" - ) - - # Prompt (remaining arguments) - parser.add_argument("prompt", nargs="+", help="Prompt to send to AI agent") - - # Set default agent - parser.set_defaults(agent="gemini") - - return parser.parse_args(args) - - -def generate_aid_completion(shell: str = "bash") -> str: - """Generate completion script for the requested shell.""" - if shell != "bash": - raise ValueError("Only bash completion is currently supported for aid") - return load_completion_script("aid") - - -def aid_completion_block(shell: str = "bash") -> str: - """Return the completion block for aid with standard markers.""" - script = generate_aid_completion(shell) - return f"{script.rstrip()}\n" - - -def install_aid_completion(shell: str = "bash", rc_path: Optional[pathlib.Path] = None) -> int: - """Install or update aid shell completion via centralized installer.""" - if shell != "bash": - logging.error("Only bash completion is currently supported for aid") - return 1 - - try: - from .completion import install_all_completions - except ImportError as error: # pragma: no cover - defensive - logging.error("Unable to load completion installer: %s", error) - return 1 - return install_all_completions(rc_path) - - -def build_ai_command( - agent: str, prompt: str, *, yolo: bool = False, flash: bool = False -) -> List[str]: - """Build the AI CLI command for the specified agent and prompt. - - Args: - agent: AI agent type ('gemini', 'claude', 'codex') - prompt: The prompt text to send to the agent - - Returns: - List of command components for execution - """ - # Escape single quotes in prompt for shell safety - escaped_prompt = prompt.replace("'", "'\"'\"'") - - def build_gemini_cmd(yolo_flag: bool, flash_flag: bool) -> List[str]: - cmd = ["gemini", "--prompt-interactive"] - if flash_flag: - cmd.extend(["--model", "gemini-2.5-flash"]) - if yolo_flag: - cmd.append("--yolo") - cmd.append(f'"{escaped_prompt}"') - return cmd - - if agent == "gemini": - return build_gemini_cmd(yolo, flash) - if agent == "claude": - # Use claude CLI - send prompt then start interactive mode - return [ - "bash", - "-c", - f"claude '{escaped_prompt}' && echo 'Starting interactive session...' && claude", - ] - if agent == "codex": - # Use openai CLI for interactive chat with GPT-4 - return [ - "bash", - "-c", - f"openai api chat.completions.create -m gpt-4 -g user '{escaped_prompt}' && echo 'Starting interactive session...' && openai api chat.completions.create -m gpt-4", - ] - raise ValueError(f"Unsupported AI agent: {agent}") - - -def run_aid(args: Optional[List[str]] = None) -> int: - """Main entry point for aid command.""" - logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") - - try: - parsed_args = parse_aid_args(args) - - # Parse repository specification - repo_spec = RepoSpec.parse(parsed_args.repo_spec) - logging.info(f"Working with: {repo_spec}") - - # Combine prompt parts into single string - prompt_text = " ".join(parsed_args.prompt) - logging.info( - f"Using {parsed_args.agent} with prompt: {prompt_text[:100]}{'...' if len(prompt_text) > 100 else ''}" - ) - - if parsed_args.flash and parsed_args.agent != "gemini": - logging.warning( - "--flash is only supported with Gemini; ignoring for %s", parsed_args.agent - ) - - # Build AI command - ai_command = build_ai_command( - parsed_args.agent, - prompt_text, - yolo=getattr(parsed_args, "yolo", False), - flash=getattr(parsed_args, "flash", False) if parsed_args.agent == "gemini" else False, - ) - - # Use renv's container management to execute the AI command - return manage_container( - repo_spec=repo_spec, - command=ai_command, - force=False, # Don't force rebuild unless needed - nocache=False, # Use cache for faster startup - no_container=False, # We need the container for AI CLI - vsc=False, # Terminal mode, not VSCode - ) - - except ValueError as e: - logging.error(f"Invalid repository specification: {e}") - return 1 - except Exception as e: - logging.error(f"Unexpected error: {e}") - return 1 - - -def main(): - """Entry point for the aid command.""" - sys.exit(run_aid()) - - -if __name__ == "__main__": - main() diff --git a/rockerc/completion.py b/rockerc/completion.py index f5156a2..243316a 100644 --- a/rockerc/completion.py +++ b/rockerc/completion.py @@ -12,6 +12,9 @@ _RC_BLOCK_START = "# >>> rockerc completions >>>" _RC_BLOCK_END = "# <<< rockerc completions <<<" +# Blocks an earlier rockerc wrote straight into the user's rc file, stripped on +# every install. The aid entries stay after aid's removal: they are how an rc +# file that still carries aid's completion gets cleaned up. _LEGACY_BLOCKS = { "# rockerc completion": "# end rockerc completion", "# renv completion": "# end renv completion", @@ -41,7 +44,7 @@ def _completion_file_path() -> pathlib.Path: def install_all_completions(rc_path: Optional[pathlib.Path] = None) -> int: - """Install or refresh completion scripts for rockerc, renv/renvvsc, and aid.""" + """Install or refresh completion scripts for rockerc, renv/renvvsc, and dp.""" completion_path = _completion_file_path().expanduser() rc_target = (rc_path if rc_path is not None else pathlib.Path.home() / ".bashrc").expanduser() @@ -51,7 +54,6 @@ def install_all_completions(rc_path: Optional[pathlib.Path] = None) -> int: combined_script_parts = [ _rockerc_bash_completion_script().rstrip(), load_completion_script("renv").rstrip(), - load_completion_script("aid").rstrip(), load_completion_script("dp").rstrip(), ] combined_script = "\n\n".join(combined_script_parts) + "\n" diff --git a/rockerc/completions/aid.bash b/rockerc/completions/aid.bash deleted file mode 100644 index 9819559..0000000 --- a/rockerc/completions/aid.bash +++ /dev/null @@ -1,74 +0,0 @@ -# aid completion -_aid_completion() { - local cur prev opts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - - opts="--help --claude --codex --gemini --yolo --flash -y -f" - - if [[ ${cur} == -* ]]; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi - - if [[ ${COMP_CWORD} -eq 1 ]]; then - local renv_root="${RENV_DIR:-$HOME/renv}" - local cache_root="$renv_root/.cache" - - if [[ "$cur" == *"#"* ]]; then - local spec_part="${cur%%#*}" - local repo_part="${spec_part%%@*}" - local branch_part="${spec_part##*@}" - local owner="${repo_part%%/*}" - local repo="${repo_part##*/}" - local safe_branch="${branch_part//\//-}" - local branch_dir="$renv_root/$owner/$repo/$safe_branch/$repo" - - if [[ -d "$branch_dir" ]]; then - local folders=$(find "$branch_dir" -type d -not -path "*/.git/*" -not -name ".git" | sed "s|$branch_dir/||" | grep -v "^$" | xargs) - local completions="" - for folder in $folders; do - completions="$completions $spec_part#$folder" - done - COMPREPLY=( $(compgen -W "${completions}" -- ${cur}) ) - fi - return 0 - elif [[ "$cur" == *"@"* ]]; then - local repo_part="${cur%%@*}" - local owner="${repo_part%%/*}" - local repo="${repo_part##*/}" - local repo_dir="$cache_root/$owner/$repo" - if [[ -d "$repo_dir" ]]; then - local branches=$(git -C "$repo_dir" branch -r 2>/dev/null | sed 's/.*origin\///' | grep -v HEAD | xargs) - local completions="" - for branch in $branches; do - completions="$completions $repo_part@$branch" - done - COMPREPLY=( $(compgen -W "${completions}" -- ${cur}) ) - fi - return 0 - else - compopt -o nospace 2>/dev/null - if [[ -d "$cache_root" ]]; then - local repos="" - local users=$(find "$cache_root" -maxdepth 1 -type d -exec basename {} \; | grep -v "^\.cache$") - for user in $users; do - if [[ -d "$cache_root/$user" ]]; then - local user_repos=$(find "$cache_root/$user" -maxdepth 1 -type d -exec basename {} \; | grep -v "^$user$") - for repo in $user_repos; do - repos="$repos $user/$repo" - done - fi - done - COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) ) - fi - return 0 - fi - fi - - return 0 -} - -complete -F _aid_completion aid -# end aid completion diff --git a/test/test_aid.py b/test/test_aid.py deleted file mode 100644 index f3c468e..0000000 --- a/test/test_aid.py +++ /dev/null @@ -1,165 +0,0 @@ -"""Tests for aid (AI Develop) command functionality.""" - -import pytest - -from rockerc.aid import ( - build_ai_command, - generate_aid_completion, - install_aid_completion, - parse_aid_args, -) - - -def test_parse_aid_args_default_gemini(): - """Test that gemini is the default agent.""" - args = parse_aid_args(["owner/repo", "test", "prompt"]) - assert args.agent == "gemini" - assert args.repo_spec == "owner/repo" - assert args.prompt == ["test", "prompt"] - - -def test_parse_aid_args_claude(): - """Test claude agent selection.""" - args = parse_aid_args(["--claude", "owner/repo", "test", "prompt"]) - assert args.agent == "claude" - assert args.repo_spec == "owner/repo" - assert args.prompt == ["test", "prompt"] - - -def test_parse_aid_args_codex(): - """Test codex agent selection.""" - args = parse_aid_args(["--codex", "owner/repo@branch", "complex", "multi", "word", "prompt"]) - assert args.agent == "codex" - assert args.repo_spec == "owner/repo@branch" - assert args.prompt == ["complex", "multi", "word", "prompt"] - - -def test_parse_aid_args_flash_flag(): - """Test flash flag parsing.""" - args = parse_aid_args(["--flash", "owner/repo", "prompt"]) - assert args.flash is True - - -def test_parse_aid_args_flash_short_flag(): - """Test short flash flag parsing.""" - args = parse_aid_args(["-f", "owner/repo", "prompt"]) - assert args.flash is True - - -def test_build_ai_command_gemini(): - """Test gemini command construction.""" - command = build_ai_command("gemini", "test prompt") - assert len(command) == 3 - assert command[0] == "gemini" - assert command[1] == "--prompt-interactive" - assert "test prompt" in command[2] - - -def test_build_ai_command_claude(): - """Test claude command construction.""" - command = build_ai_command("claude", "test prompt") - assert len(command) == 3 - assert command[0] == "bash" - assert command[1] == "-c" - assert "claude" in command[2] - assert "test prompt" in command[2] - - -def test_build_ai_command_codex(): - """Test codex command construction.""" - command = build_ai_command("codex", "test prompt") - assert len(command) == 3 - assert command[0] == "bash" - assert command[1] == "-c" - assert "openai" in command[2] - assert "test prompt" in command[2] - - -def test_build_ai_command_quote_escaping(): - """Test that single quotes in prompts are properly escaped.""" - command = build_ai_command("gemini", "test 'quoted' prompt") - # Check that the command contains properly escaped quotes - assert "test '\"'\"'quoted'\"'\"' prompt" in command[2] or "test" in command[2] - - -def test_build_ai_command_invalid_agent(): - """Test that invalid agent raises ValueError.""" - with pytest.raises(ValueError, match="Unsupported AI agent"): - build_ai_command("invalid_agent", "test prompt") - - -def test_parse_aid_args_missing_arguments(): - """Test that missing arguments raises SystemExit (argparse behavior).""" - with pytest.raises(SystemExit): - parse_aid_args(["owner/repo"]) # Missing prompt - - -def test_parse_aid_args_mutually_exclusive_agents(): - """Test that multiple agents can't be specified.""" - with pytest.raises(SystemExit): - parse_aid_args(["--gemini", "--claude", "owner/repo", "prompt"]) - - -def test_parse_aid_args_repo_with_subfolder(): - """Test parsing repo spec with subfolder.""" - args = parse_aid_args(["owner/repo#subfolder", "test", "prompt"]) - assert args.repo_spec == "owner/repo#subfolder" - assert args.prompt == ["test", "prompt"] - - -def test_build_ai_command_flash_adds_model(): - """Gemini flash flag adds model argument.""" - command = build_ai_command("gemini", "prompt", flash=True) - assert "--model" in command - assert "gemini-2.5-flash" in command - - -def test_build_ai_command_flash_ignored_for_non_gemini(): - """Flash flag is ignored for non-gemini agents.""" - command = build_ai_command("claude", "prompt", flash=True) - assert "--model" not in command - - -def test_generate_aid_completion_only_bash(): - """Only bash completion is supported.""" - with pytest.raises(ValueError, match="Only bash completion"): - generate_aid_completion("zsh") - - -def test_install_aid_completion_overwrites_existing(tmp_path, monkeypatch): - """Ensure install overwrites previous installation.""" - completion_file = tmp_path / "completions.sh" - monkeypatch.setenv("ROCKERC_COMPLETION_FILE", str(completion_file)) - - rc_file = tmp_path / "bashrc" - rc_file.write_text( - "# aid completion\nold content\ncomplete -F _aid_completion aid\n", - encoding="utf-8", - ) - result = install_aid_completion(rc_path=rc_file) - assert result == 0 - written = rc_file.read_text(encoding="utf-8") - assert "# aid completion" not in written - assert "complete -F _aid_completion aid" not in written - assert "# >>> rockerc completions >>>" in written - assert str(completion_file) in written - - completions_content = completion_file.read_text(encoding="utf-8") - assert completions_content.count("# aid completion") == 1 - assert "old content" not in completions_content - - -def test_install_aid_completion_creates_file(tmp_path, monkeypatch): - """Install should create rc file when missing.""" - completion_file = tmp_path / "completions.sh" - monkeypatch.setenv("ROCKERC_COMPLETION_FILE", str(completion_file)) - - rc_file = tmp_path / "bashrc" - result = install_aid_completion(rc_path=rc_file) - assert result == 0 - assert rc_file.exists() - content = rc_file.read_text(encoding="utf-8") - assert "# >>> rockerc completions >>>" in content - assert str(completion_file) in content - completions_content = completion_file.read_text(encoding="utf-8") - assert "# aid completion" in completions_content diff --git a/test/test_completion_install.py b/test/test_completion_install.py index c41ddce..ec41ce0 100644 --- a/test/test_completion_install.py +++ b/test/test_completion_install.py @@ -27,11 +27,35 @@ def test_install_shell_completion_refreshes(tmp_path, monkeypatch): assert "outdated" not in completions_content assert completions_content.count("# renv completion") == 1 assert completions_content.count("# rockerc completion") == 1 - assert completions_content.count("# aid completion") == 1 + assert completions_content.count("# dp completion") == 1 assert "-exec basename {} \\;" in completions_content assert "\\\\;" not in completions_content +def test_install_removes_a_leftover_aid_completion(tmp_path, monkeypatch): + """aid is gone, so installing has to take its completion out of the rc file. + + Anyone upgrading past aid's removal still has aid's block and its `complete` + line in ~/.bashrc, completing a command that no longer exists. + """ + completion_file = tmp_path / "completions.sh" + monkeypatch.setenv("ROCKERC_COMPLETION_FILE", str(completion_file)) + + rc_file = tmp_path / "bashrc" + rc_file.write_text( + "# aid completion\n_aid_completion() { :; }\n# end aid completion\n" + "complete -F _aid_completion aid\n", + encoding="utf-8", + ) + + assert install_all_completions(rc_file) == 0 + + rc_content = rc_file.read_text(encoding="utf-8") + assert "aid" not in rc_content + assert "# >>> rockerc completions >>>" in rc_content + assert "aid" not in completion_file.read_text(encoding="utf-8") + + def test_install_all_completions_idempotent(tmp_path, monkeypatch): """rockerc --install refreshes source block and overwrites completion file.""" completion_file = tmp_path / "completions.sh" @@ -46,7 +70,7 @@ def test_install_all_completions_idempotent(tmp_path, monkeypatch): assert f'source "{completion_file}"' in first_rc assert first_completion.count("# rockerc completion") == 1 assert first_completion.count("# renv completion") == 1 - assert first_completion.count("# aid completion") == 1 + assert first_completion.count("# dp completion") == 1 # Overwrite with stale content to confirm reinstall replaces it. completion_file.write_text("stale\n", encoding="utf-8") @@ -60,6 +84,6 @@ def test_install_all_completions_idempotent(tmp_path, monkeypatch): assert second_completion != "stale\n" assert second_completion.count("# rockerc completion") == 1 assert second_completion.count("# renv completion") == 1 - assert second_completion.count("# aid completion") == 1 + assert second_completion.count("# dp completion") == 1 assert "-exec basename {} \\;" in second_completion assert "\\\\;" not in second_completion