code-puppy 0.0.43__tar.gz → 0.0.45__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code_puppy-0.0.43 → code_puppy-0.0.45}/PKG-INFO +1 -1
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/agent.py +4 -2
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/meta_command_handler.py +3 -1
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/model_picker_completion.py +11 -11
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/config.py +15 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/pyproject.toml +1 -1
- {code_puppy-0.0.43 → code_puppy-0.0.45}/.gitignore +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/LICENSE +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/README.md +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/__init__.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/agent_prompts.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/__init__.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/file_path_completion.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/prompt_toolkit_completion.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/utils.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/main.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/model_factory.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/models.json +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/session_memory.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/__init__.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/code_map.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/command_runner.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/common.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/file_modifications.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/file_operations.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/tools/web_search.py +0 -0
- {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/version_checker.py +0 -0
| @@ -50,7 +50,8 @@ def session_memory(): | |
| 50 50 | 
             
            def reload_code_generation_agent():
         | 
| 51 51 | 
             
                """Force-reload the agent, usually after a model change."""
         | 
| 52 52 | 
             
                global _code_generation_agent, _LAST_MODEL_NAME
         | 
| 53 | 
            -
                 | 
| 53 | 
            +
                from code_puppy.config import get_model_name
         | 
| 54 | 
            +
                model_name = get_model_name()
         | 
| 54 55 | 
             
                console.print(f'[bold cyan]Loading Model: {model_name}[/bold cyan]')
         | 
| 55 56 | 
             
                models_path = Path(MODELS_JSON_PATH) if MODELS_JSON_PATH else Path(__file__).parent / "models.json"
         | 
| 56 57 | 
             
                model = ModelFactory.get_model(model_name, ModelFactory.load_config(models_path))
         | 
| @@ -79,7 +80,8 @@ def get_code_generation_agent(force_reload=False): | |
| 79 80 | 
             
                Forces a reload if the model has changed, or if force_reload is passed.
         | 
| 80 81 | 
             
                """
         | 
| 81 82 | 
             
                global _code_generation_agent, _LAST_MODEL_NAME
         | 
| 82 | 
            -
                 | 
| 83 | 
            +
                from code_puppy.config import get_model_name
         | 
| 84 | 
            +
                model_name = get_model_name()
         | 
| 83 85 | 
             
                if _code_generation_agent is None or _LAST_MODEL_NAME != model_name or force_reload:
         | 
| 84 86 | 
             
                    return reload_code_generation_agent()
         | 
| 85 87 | 
             
                return _code_generation_agent
         | 
| @@ -48,8 +48,10 @@ def handle_meta_command(command: str, console: Console) -> bool: | |
| 48 48 | 
             
                    # Try setting model and show confirmation
         | 
| 49 49 | 
             
                    new_input = update_model_in_input(command)
         | 
| 50 50 | 
             
                    if new_input is not None:
         | 
| 51 | 
            +
                        from code_puppy.agent import get_code_generation_agent
         | 
| 51 52 | 
             
                        model = get_active_model()
         | 
| 52 | 
            -
                         | 
| 53 | 
            +
                        get_code_generation_agent(force_reload=True)
         | 
| 54 | 
            +
                        console.print(f"[bold green]Active model set and loaded:[/bold green] [cyan]{model}[/cyan]")
         | 
| 53 55 | 
             
                        return True
         | 
| 54 56 | 
             
                    # If no model matched, show available models
         | 
| 55 57 | 
             
                    model_names = load_model_names()
         | 
| @@ -5,12 +5,12 @@ from prompt_toolkit.completion import Completer, Completion | |
| 5 5 | 
             
            from prompt_toolkit.history import FileHistory
         | 
| 6 6 | 
             
            from prompt_toolkit.document import Document
         | 
| 7 7 | 
             
            from prompt_toolkit import PromptSession
         | 
| 8 | 
            +
            from code_puppy.config import get_model_name, set_model_name
         | 
| 8 9 |  | 
| 9 10 | 
             
            MODELS_JSON_PATH = os.environ.get("MODELS_JSON_PATH")
         | 
| 10 11 | 
             
            if not MODELS_JSON_PATH:
         | 
| 11 12 | 
             
                MODELS_JSON_PATH = os.path.join(os.path.dirname(__file__), '..', 'models.json')
         | 
| 12 13 | 
             
                MODELS_JSON_PATH = os.path.abspath(MODELS_JSON_PATH)
         | 
| 13 | 
            -
            MODEL_STATE_PATH = os.path.expanduser('~/.code_puppy_model')
         | 
| 14 14 |  | 
| 15 15 | 
             
            def load_model_names():
         | 
| 16 16 | 
             
                with open(MODELS_JSON_PATH, 'r') as f:
         | 
| @@ -18,18 +18,18 @@ def load_model_names(): | |
| 18 18 | 
             
                return list(models.keys())
         | 
| 19 19 |  | 
| 20 20 | 
             
            def get_active_model():
         | 
| 21 | 
            -
                 | 
| 22 | 
            -
                 | 
| 23 | 
            -
             | 
| 24 | 
            -
                 | 
| 25 | 
            -
             | 
| 26 | 
            -
                        return f.read().strip()
         | 
| 27 | 
            -
                except Exception:
         | 
| 28 | 
            -
                    return None
         | 
| 21 | 
            +
                """
         | 
| 22 | 
            +
                Returns the active model from the config using get_model_name().
         | 
| 23 | 
            +
                This ensures consistency across the codebase by always using the config value.
         | 
| 24 | 
            +
                """
         | 
| 25 | 
            +
                return get_model_name()
         | 
| 29 26 |  | 
| 30 27 | 
             
            def set_active_model(model_name: str):
         | 
| 31 | 
            -
                 | 
| 32 | 
            -
             | 
| 28 | 
            +
                """
         | 
| 29 | 
            +
                Sets the active model name by updating both config (for persistence)
         | 
| 30 | 
            +
                and env (for process lifetime override).
         | 
| 31 | 
            +
                """
         | 
| 32 | 
            +
                set_model_name(model_name)
         | 
| 33 33 | 
             
                os.environ['MODEL_NAME'] = model_name.strip()
         | 
| 34 34 | 
             
                # Reload agent globally
         | 
| 35 35 | 
             
                try:
         | 
| @@ -51,3 +51,18 @@ def get_puppy_name(): | |
| 51 51 |  | 
| 52 52 | 
             
            def get_owner_name():
         | 
| 53 53 | 
             
                return get_value("owner_name") or "Master"
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            # --- MODEL STICKY EXTENSION STARTS HERE ---
         | 
| 56 | 
            +
            def get_model_name():
         | 
| 57 | 
            +
                """Returns the last used model name stored in config, or None if unset."""
         | 
| 58 | 
            +
                return get_value("model") or "gpt-4o"
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            def set_model_name(model: str):
         | 
| 61 | 
            +
                """Sets the model name in the persistent config file."""
         | 
| 62 | 
            +
                config = configparser.ConfigParser()
         | 
| 63 | 
            +
                config.read(CONFIG_FILE)
         | 
| 64 | 
            +
                if DEFAULT_SECTION not in config:
         | 
| 65 | 
            +
                    config[DEFAULT_SECTION] = {}
         | 
| 66 | 
            +
                config[DEFAULT_SECTION]["model"] = model or ""
         | 
| 67 | 
            +
                with open(CONFIG_FILE, "w") as f:
         | 
| 68 | 
            +
                    config.write(f)
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
    
        {code_puppy-0.0.43 → code_puppy-0.0.45}/code_puppy/command_line/prompt_toolkit_completion.py
    RENAMED
    
    | 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |