code-puppy 0.0.42__tar.gz → 0.0.44__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.42 → code_puppy-0.0.44}/PKG-INFO +1 -1
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/model_picker_completion.py +16 -8
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/prompt_toolkit_completion.py +10 -1
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/config.py +15 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/pyproject.toml +1 -1
- {code_puppy-0.0.42 → code_puppy-0.0.44}/.gitignore +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/LICENSE +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/README.md +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/__init__.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/agent.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/agent_prompts.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/__init__.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/file_path_completion.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/meta_command_handler.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/utils.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/main.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/model_factory.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/models.json +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/session_memory.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/__init__.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/code_map.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/command_runner.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/common.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/file_modifications.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/file_operations.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/tools/web_search.py +0 -0
- {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/version_checker.py +0 -0
| @@ -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,26 @@ def load_model_names(): | |
| 18 18 | 
             
                return list(models.keys())
         | 
| 19 19 |  | 
| 20 20 | 
             
            def get_active_model():
         | 
| 21 | 
            +
                """
         | 
| 22 | 
            +
                Returns the active model in order of priority:
         | 
| 23 | 
            +
                1. Model stored in config (sticky, highest priority)
         | 
| 24 | 
            +
                2. MODEL_NAME environment variable (for temporary override/testing)
         | 
| 25 | 
            +
                3. None if unset
         | 
| 26 | 
            +
                """
         | 
| 27 | 
            +
                model = get_model_name()
         | 
| 28 | 
            +
                if model:
         | 
| 29 | 
            +
                    return model
         | 
| 21 30 | 
             
                env_model = os.environ.get('MODEL_NAME')
         | 
| 22 31 | 
             
                if env_model:
         | 
| 23 32 | 
             
                    return env_model
         | 
| 24 | 
            -
                 | 
| 25 | 
            -
                    with open(MODEL_STATE_PATH, 'r') as f:
         | 
| 26 | 
            -
                        return f.read().strip()
         | 
| 27 | 
            -
                except Exception:
         | 
| 28 | 
            -
                    return None
         | 
| 33 | 
            +
                return None
         | 
| 29 34 |  | 
| 30 35 | 
             
            def set_active_model(model_name: str):
         | 
| 31 | 
            -
                 | 
| 32 | 
            -
             | 
| 36 | 
            +
                """
         | 
| 37 | 
            +
                Sets the active model name by updating both config (for persistence)
         | 
| 38 | 
            +
                and env (for process lifetime override).
         | 
| 39 | 
            +
                """
         | 
| 40 | 
            +
                set_model_name(model_name)
         | 
| 33 41 | 
             
                os.environ['MODEL_NAME'] = model_name.strip()
         | 
| 34 42 | 
             
                # Reload agent globally
         | 
| 35 43 | 
             
                try:
         | 
    
        {code_puppy-0.0.42 → code_puppy-0.0.44}/code_puppy/command_line/prompt_toolkit_completion.py
    RENAMED
    
    | @@ -15,6 +15,8 @@ from prompt_toolkit import PromptSession | |
| 15 15 | 
             
            from prompt_toolkit.completion import merge_completers
         | 
| 16 16 | 
             
            from prompt_toolkit.history import FileHistory
         | 
| 17 17 | 
             
            from prompt_toolkit.styles import Style
         | 
| 18 | 
            +
            from prompt_toolkit.key_binding import KeyBindings
         | 
| 19 | 
            +
            from prompt_toolkit.keys import Keys
         | 
| 18 20 |  | 
| 19 21 | 
             
            from code_puppy.command_line.model_picker_completion import (
         | 
| 20 22 | 
             
                ModelNameCompleter,
         | 
| @@ -83,10 +85,17 @@ async def get_input_with_combined_completion(prompt_str = '>>> ', history_file: | |
| 83 85 | 
             
                    ModelNameCompleter(trigger='~m'),
         | 
| 84 86 | 
             
                    CDCompleter(trigger='~cd'),
         | 
| 85 87 | 
             
                ])
         | 
| 88 | 
            +
                # Add custom key bindings for Alt+M to insert a new line without submitting
         | 
| 89 | 
            +
                bindings = KeyBindings()
         | 
| 90 | 
            +
                @bindings.add(Keys.Escape, 'm')  # Alt+M
         | 
| 91 | 
            +
                def _(event):
         | 
| 92 | 
            +
                    event.app.current_buffer.insert_text('\n')
         | 
| 93 | 
            +
             | 
| 86 94 | 
             
                session = PromptSession(
         | 
| 87 95 | 
             
                    completer=completer,
         | 
| 88 96 | 
             
                    history=history,
         | 
| 89 | 
            -
                    complete_while_typing=True
         | 
| 97 | 
            +
                    complete_while_typing=True,
         | 
| 98 | 
            +
                    key_bindings=bindings
         | 
| 90 99 | 
             
                )
         | 
| 91 100 | 
             
                # If they pass a string, backward-compat: convert it to formatted_text
         | 
| 92 101 | 
             
                if isinstance(prompt_str, str):
         | 
| @@ -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")
         | 
| 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
         | 
| 
            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
         | 
| 
            File without changes
         |