patchpal 0.1.5__tar.gz → 0.2.1__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.
Files changed (27) hide show
  1. {patchpal-0.1.5/patchpal.egg-info → patchpal-0.2.1}/PKG-INFO +245 -52
  2. {patchpal-0.1.5 → patchpal-0.2.1}/README.md +244 -51
  3. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/__init__.py +1 -1
  4. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/agent.py +225 -1
  5. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/cli.py +17 -1
  6. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/system_prompt.md +13 -1
  7. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/tools.py +632 -5
  8. {patchpal-0.1.5 → patchpal-0.2.1/patchpal.egg-info}/PKG-INFO +245 -52
  9. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_agent.py +13 -3
  10. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_tools.py +594 -0
  11. {patchpal-0.1.5 → patchpal-0.2.1}/LICENSE +0 -0
  12. {patchpal-0.1.5 → patchpal-0.2.1}/MANIFEST.in +0 -0
  13. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/context.py +0 -0
  14. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/permissions.py +0 -0
  15. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal/skills.py +0 -0
  16. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal.egg-info/SOURCES.txt +0 -0
  17. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal.egg-info/dependency_links.txt +0 -0
  18. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal.egg-info/entry_points.txt +0 -0
  19. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal.egg-info/requires.txt +0 -0
  20. {patchpal-0.1.5 → patchpal-0.2.1}/patchpal.egg-info/top_level.txt +0 -0
  21. {patchpal-0.1.5 → patchpal-0.2.1}/pyproject.toml +0 -0
  22. {patchpal-0.1.5 → patchpal-0.2.1}/setup.cfg +0 -0
  23. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_cli.py +0 -0
  24. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_context.py +0 -0
  25. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_guardrails.py +0 -0
  26. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_operational_safety.py +0 -0
  27. {patchpal-0.1.5 → patchpal-0.2.1}/tests/test_skills.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchpal
3
- Version: 0.1.5
3
+ Version: 0.2.1
4
4
  Summary: A lean Claude Code clone in pure Python
5
5
  Author: PatchPal Contributors
6
6
  License-Expression: Apache-2.0
@@ -46,6 +46,30 @@ Dynamic: license-file
46
46
 
47
47
  A key goal of this project is to approximate Claude Code's core functionality while remaining lean, accessible, and configurable, enabling learning, experimentation, and broad applicability across use cases.
48
48
 
49
+ ## Table of Contents
50
+
51
+ - [Installation](https://github.com/amaiya/patchpal?tab=readme-ov-file#installation)
52
+ - [Setup](https://github.com/amaiya/patchpal?tab=readme-ov-file#setup)
53
+ - [Features](https://github.com/amaiya/patchpal?tab=readme-ov-file#features)
54
+ - [Tools](https://github.com/amaiya/patchpal?tab=readme-ov-file#tools)
55
+ - [File Operations](https://github.com/amaiya/patchpal?tab=readme-ov-file#file-operations)
56
+ - [Task Planning (TODO System)](https://github.com/amaiya/patchpal?tab=readme-ov-file#task-planning-todo-system)
57
+ - [User Interaction](https://github.com/amaiya/patchpal?tab=readme-ov-file#user-interaction)
58
+ - [Git Operations](https://github.com/amaiya/patchpal?tab=readme-ov-file#git-operations-no-permission-required)
59
+ - [Web Capabilities](https://github.com/amaiya/patchpal?tab=readme-ov-file#web-capabilities-requires-permission)
60
+ - [Skills System](https://github.com/amaiya/patchpal?tab=readme-ov-file#skills-system)
61
+ - [Model Configuration](https://github.com/amaiya/patchpal?tab=readme-ov-file#model-configuration)
62
+ - [Supported Models](https://github.com/amaiya/patchpal?tab=readme-ov-file#supported-models)
63
+ - [Using Local Models (vLLM & Ollama)](https://github.com/amaiya/patchpal?tab=readme-ov-file#using-local-models-vllm--ollama)
64
+ - [Air-Gapped and Offline Environments](https://github.com/amaiya/patchpal?tab=readme-ov-file#air-gapped-and-offline-environments)
65
+ - [Maximum Security Mode](https://github.com/amaiya/patchpal?tab=readme-ov-file#maximum-security-mode)
66
+ - [Usage](https://github.com/amaiya/patchpal?tab=readme-ov-file#usage)
67
+ - [Configuration](https://github.com/amaiya/patchpal?tab=readme-ov-file#configuration)
68
+ - [Example Tasks](https://github.com/amaiya/patchpal?tab=readme-ov-file#example-tasks)
69
+ - [Safety](https://github.com/amaiya/patchpal?tab=readme-ov-file#safety)
70
+ - [Context Management](https://github.com/amaiya/patchpal?tab=readme-ov-file#context-management)
71
+ - [Troubleshooting](https://github.com/amaiya/patchpal?tab=readme-ov-file#troubleshooting)
72
+
49
73
 
50
74
  ```bash
51
75
  $ls ./patchpal
@@ -121,6 +145,10 @@ The agent has the following tools:
121
145
 
122
146
  ### File Operations
123
147
  - **read_file**: Read contents of files in the repository
148
+ - **read_lines**: Read specific line ranges from a file without loading the entire file
149
+ - Example: `read_lines("app.py", 100, 150)` - read lines 100-150
150
+ - More efficient than read_file when you only need a few lines
151
+ - Useful for viewing code sections, error context, or specific regions of large files
124
152
  - **list_files**: List all files in the repository
125
153
  - **get_file_info**: Get detailed metadata for file(s) - size, modification time, type
126
154
  - Supports single files: `get_file_info("file.txt")`
@@ -143,6 +171,29 @@ The agent has the following tools:
143
171
  - **apply_patch**: Modify files by providing complete new content
144
172
  - **run_shell**: Execute shell commands (requires user permission; privilege escalation blocked)
145
173
 
174
+ ### Task Planning (TODO System)
175
+ - **todo_add**: Add a new task to break down complex work into manageable subtasks
176
+ - Example: `todo_add("Implement authentication", details="Use JWT tokens")`
177
+ - Each task gets a unique ID for tracking
178
+ - **todo_list**: Show all tasks with their status and progress
179
+ - Example: `todo_list()` - show pending tasks only
180
+ - Example: `todo_list(show_completed=True)` - show all tasks including completed
181
+ - **todo_complete**: Mark a task as done
182
+ - Example: `todo_complete(1)` - mark task #1 as completed
183
+ - **todo_update**: Update task description or details
184
+ - Example: `todo_update(1, description="Implement OAuth2 authentication")`
185
+ - **todo_remove**: Remove a task from the list
186
+ - Example: `todo_remove(1)` - remove task #1
187
+ - **todo_clear**: Clear completed tasks or start fresh
188
+ - Example: `todo_clear()` - clear completed tasks only
189
+ - Example: `todo_clear(completed_only=False)` - clear all tasks
190
+
191
+ ### User Interaction
192
+ - **ask_user**: Ask the user a question during task execution
193
+ - Example: `ask_user("Which database should I use?", options=["PostgreSQL", "MySQL", "SQLite"])`
194
+ - Useful for clarifying requirements, getting decisions, or gathering additional information
195
+ - Supports multiple choice options or free-form answers
196
+
146
197
  ### Git Operations (No Permission Required)
147
198
  - **git_status**: Show modified, staged, and untracked files
148
199
  - **git_diff**: Show changes in working directory or staged area
@@ -436,6 +487,7 @@ docker rm ollama
436
487
 
437
488
  # Start with proper configuration
438
489
  docker run -d \
490
+ --gpus all \
439
491
  -e OLLAMA_CONTEXT_LENGTH=32768 \
440
492
  -v ollama:/root/.ollama \
441
493
  -p 11434:11434 \
@@ -513,6 +565,80 @@ When web tools are disabled:
513
565
  patchpal --help
514
566
  ```
515
567
 
568
+ ### Maximum Security Mode
569
+
570
+ For maximum security and control, you can require permission for **all** operations including read operations:
571
+
572
+ ```bash
573
+ patchpal --require-permission-for-all
574
+ ```
575
+
576
+ When enabled, the agent will prompt for permission before:
577
+ - **Read operations**: `read_file`, `list_files`, `get_file_info`, `find_files`, `tree`, `grep_code`, `git_status`, `git_diff`, `git_log`
578
+ - **Write operations**: `edit_file`, `apply_patch` (always require permission)
579
+ - **Shell commands**: `run_shell` (always requires permission)
580
+ - **Web operations**: `web_search`, `web_fetch` (always require permission)
581
+
582
+ **Granular session permissions:**
583
+ When you grant permission for read operations, you can choose to grant it for:
584
+ - **This specific operation only** (option 1)
585
+ - **This specific file/pattern for the session** (option 2) - e.g., grant permission to read `config.py` for the session, but still prompt for other files
586
+ - **Cancel the operation** (option 3)
587
+
588
+ This provides fine-grained control over what the agent can access during the session.
589
+
590
+ **Use cases:**
591
+ - Working with highly sensitive codebases
592
+ - Security audits where every operation must be reviewed
593
+ - Training/demonstration purposes where you want to see exactly what the agent does
594
+ - Untrusted environments where you want complete control
595
+
596
+ **Example session:**
597
+ ```bash
598
+ $ patchpal --require-permission-for-all
599
+ ================================================================================
600
+ PatchPal - Claude Code–inspired coding and automation assistant
601
+ ================================================================================
602
+
603
+ Using model: anthropic/claude-sonnet-4-5
604
+ 🔒 Permission required for ALL operations (including reads)
605
+
606
+ You: Read config.py and database.py
607
+
608
+ ================================================================================
609
+ Read File
610
+ --------------------------------------------------------------------------------
611
+ Read: config.py
612
+ --------------------------------------------------------------------------------
613
+
614
+ Do you want to proceed?
615
+ 1. Yes
616
+ 2. Yes, and don't ask again this session for 'config.py'
617
+ 3. No, and tell me what to do differently
618
+
619
+ Choice [1-3]: 2
620
+
621
+ # Agent reads config.py, then prompts for database.py
622
+
623
+ ================================================================================
624
+ Read File
625
+ --------------------------------------------------------------------------------
626
+ Read: database.py
627
+ --------------------------------------------------------------------------------
628
+
629
+ Do you want to proceed?
630
+ 1. Yes
631
+ 2. Yes, and don't ask again this session for 'database.py'
632
+ 3. No, and tell me what to do differently
633
+
634
+ Choice [1-3]: 1
635
+
636
+ # Agent reads database.py, but will prompt again if it tries to read it later
637
+ # Won't prompt again for config.py since you chose option 2
638
+ ```
639
+
640
+ **Note:** This mode is separate from and overrides `PATCHPAL_REQUIRE_PERMISSION=false`. Even if you've disabled the standard permission system, `--require-permission-for-all` will still prompt for all operations.
641
+
516
642
  ## Usage
517
643
 
518
644
  Simply run the `patchpal` command and type your requests interactively:
@@ -542,6 +668,116 @@ The agent will process your request and show you the results. You can continue w
542
668
  - **Interrupt Agent**: Press `Ctrl-C` during agent execution to stop the current task without exiting PatchPal
543
669
  - **Exit**: Type `exit`, `quit`, or press `Ctrl-C` at the prompt to exit PatchPal
544
670
 
671
+ ## Configuration
672
+
673
+ PatchPal can be configured through `PATCHPAL_*` environment variables to customize behavior, security, and performance.
674
+
675
+ ### Model Selection
676
+
677
+ ```bash
678
+ export PATCHPAL_MODEL=openai/gpt-4o # Override default model
679
+ # Priority: CLI arg > PATCHPAL_MODEL env var > default (anthropic/claude-sonnet-4-5)
680
+ ```
681
+
682
+ ### Security & Permissions
683
+
684
+ ```bash
685
+ # Permission System
686
+ export PATCHPAL_REQUIRE_PERMISSION=true # Prompt before executing commands/modifying files (default: true)
687
+ # ⚠️ WARNING: Setting to false disables prompts - only use in trusted environments
688
+
689
+ # File Safety
690
+ export PATCHPAL_MAX_FILE_SIZE=10485760 # Maximum file size in bytes for read/write (default: 10MB)
691
+ export PATCHPAL_READ_ONLY=true # Prevent ALL file modifications (default: false)
692
+ # Useful for: code review, exploration, security audits
693
+ export PATCHPAL_ALLOW_SENSITIVE=true # Allow access to .env, credentials (default: false - blocked)
694
+ # Only enable with test/dummy credentials
695
+
696
+ # Command Safety
697
+ export PATCHPAL_ALLOW_SUDO=true # Allow sudo/privilege escalation (default: false - blocked)
698
+ # ⚠️ WARNING: Only enable in trusted, controlled environments
699
+ export PATCHPAL_SHELL_TIMEOUT=60 # Shell command timeout in seconds (default: 30)
700
+ ```
701
+
702
+ ### Operational Controls
703
+
704
+ ```bash
705
+ # Logging & Auditing
706
+ export PATCHPAL_AUDIT_LOG=false # Log operations to ~/.patchpal/<repo-name>/audit.log (default: true)
707
+ export PATCHPAL_ENABLE_BACKUPS=true # Auto-backup files before modification (default: false)
708
+
709
+ # Resource Limits
710
+ export PATCHPAL_MAX_OPERATIONS=10000 # Max operations per session (default: 10000)
711
+ export PATCHPAL_MAX_ITERATIONS=150 # Max agent iterations per task (default: 100)
712
+ # Increase for complex multi-file tasks
713
+ ```
714
+
715
+ ### Context Window Management
716
+
717
+ ```bash
718
+ # Auto-Compaction
719
+ export PATCHPAL_DISABLE_AUTOCOMPACT=true # Disable auto-compaction (default: false - enabled)
720
+ export PATCHPAL_COMPACT_THRESHOLD=0.85 # Trigger compaction at % full (default: 0.85 = 85%)
721
+
722
+ # Context Limits
723
+ export PATCHPAL_CONTEXT_LIMIT=100000 # Override model's context limit (for testing)
724
+ # Leave unset to use model's actual capacity
725
+
726
+ # Pruning Controls
727
+ export PATCHPAL_PRUNE_PROTECT=40000 # Keep last N tokens of tool outputs (default: 40000)
728
+ export PATCHPAL_PRUNE_MINIMUM=20000 # Minimum tokens to prune (default: 20000)
729
+ ```
730
+
731
+ ### Web Tools
732
+
733
+ ```bash
734
+ # Enable/Disable Web Access
735
+ export PATCHPAL_ENABLE_WEB=false # Disable web search/fetch for air-gapped environments (default: true)
736
+
737
+ # Web Request Limits
738
+ export PATCHPAL_WEB_TIMEOUT=60 # Web request timeout in seconds (default: 30)
739
+ export PATCHPAL_MAX_WEB_SIZE=10485760 # Max web content size in bytes (default: 5MB)
740
+ export PATCHPAL_MAX_WEB_CHARS=500000 # Max characters from web content (default: 500k ≈ 125k tokens)
741
+ ```
742
+
743
+ ### Custom System Prompt
744
+
745
+ ```bash
746
+ export PATCHPAL_SYSTEM_PROMPT=~/.patchpal/my_prompt.md # Use custom system prompt
747
+ # File can use template variables: {current_date}, {platform_info}
748
+ # Useful for: custom behavior, team standards, domain-specific instructions
749
+ ```
750
+
751
+ ### Configuration Examples
752
+
753
+ **Air-Gapped Environment (Offline, No Web Access):**
754
+ ```bash
755
+ export PATCHPAL_ENABLE_WEB=false
756
+ patchpal --model hosted_vllm/openai/gpt-oss-20b
757
+ ```
758
+
759
+ **Maximum Security (Read-Only Analysis):**
760
+ ```bash
761
+ export PATCHPAL_READ_ONLY=true
762
+ export PATCHPAL_REQUIRE_PERMISSION=true
763
+ patchpal --require-permission-for-all
764
+ ```
765
+
766
+ **Testing Context Management:**
767
+ ```bash
768
+ export PATCHPAL_CONTEXT_LIMIT=10000 # Small limit to trigger compaction quickly
769
+ export PATCHPAL_COMPACT_THRESHOLD=0.75 # Trigger at 75% instead of 85%
770
+ export PATCHPAL_PRUNE_PROTECT=500 # Keep only last 500 tokens
771
+ patchpal
772
+ ```
773
+
774
+ **Autonomous Mode (Trusted Environment Only):**
775
+ ```bash
776
+ export PATCHPAL_REQUIRE_PERMISSION=false # ⚠️ Disables all permission prompts
777
+ export PATCHPAL_MAX_ITERATIONS=200 # Allow longer runs
778
+ patchpal
779
+ ```
780
+
545
781
  ## Example Tasks
546
782
 
547
783
  ```
@@ -605,43 +841,7 @@ PatchPal includes comprehensive security protections enabled by default:
605
841
  - **Resource limits**: Configurable operation counter prevents infinite loops (10000 operations default)
606
842
  - **Git state awareness**: Warns when modifying files with uncommitted changes
607
843
 
608
- **Configuration via environment variables:**
609
- ```bash
610
- # Critical Security Controls
611
- export PATCHPAL_REQUIRE_PERMISSION=true # Prompt for permission before executing commands/modifying files (default: true)
612
- # ⚠️ WARNING: Setting to false disables prompts - only use in trusted, controlled environments
613
- # When disabled, the agent can modify files and run commands without asking
614
- export PATCHPAL_MAX_FILE_SIZE=5242880 # Maximum file size in bytes for read/write operations (default: 10485760 = 10MB)
615
- export PATCHPAL_READ_ONLY=true # Prevent all file modifications, analysis-only mode (default: false)
616
- # Useful for: code review, exploration, security audits, CI/CD analysis, or trying PatchPal risk-free
617
- export PATCHPAL_ALLOW_SENSITIVE=true # Allow access to .env, credentials, API keys (default: false - blocked for safety)
618
- # Only enable when working with test/dummy credentials or intentionally managing config files
619
- export PATCHPAL_ALLOW_SUDO=true # Allow sudo commands (default: false - blocked for safety)
620
- # ⚠️ WARNING: Only enable in trusted, controlled environments where sudo is necessary
621
- # When enabled, all privilege escalation blocking is disabled
622
-
623
- # Operational Safety Controls
624
- export PATCHPAL_AUDIT_LOG=false # Log all operations to ~/.patchpal/<repo-name>/audit.log (default: true)
625
- export PATCHPAL_ENABLE_BACKUPS=true # Auto-backup files to ~/.patchpal/<repo-name>/backups/ before modification (default: false)
626
- export PATCHPAL_MAX_OPERATIONS=5000 # Maximum operations per session to prevent infinite loops (default: 10000)
627
- export PATCHPAL_MAX_ITERATIONS=150 # Maximum agent iterations per task (default: 100)
628
- # Increase for very complex multi-file tasks, decrease for testing
629
-
630
- # Customization
631
- export PATCHPAL_SYSTEM_PROMPT=~/.patchpal/my_prompt.md # Use custom system prompt file (default: built-in prompt)
632
- # The file can use template variables like {current_date}, {platform_info}, etc.
633
- # Useful for: custom agent behavior, team standards, domain-specific instructions
634
-
635
- # Web Tool Controls
636
- export PATCHPAL_ENABLE_WEB=false # Enable/disable web search and fetch tools (default: true)
637
- # Set to false for air-gapped or offline environments
638
- export PATCHPAL_WEB_TIMEOUT=60 # Timeout for web requests in seconds (default: 30)
639
- export PATCHPAL_MAX_WEB_SIZE=10485760 # Maximum web content size in bytes (default: 5242880 = 5MB)
640
- export PATCHPAL_MAX_WEB_CHARS=500000 # Maximum characters from web content to prevent context overflow (default: 500000 ≈ 125k tokens)
641
-
642
- # Shell Command Controls
643
- export PATCHPAL_SHELL_TIMEOUT=60 # Timeout for shell commands in seconds (default: 30)
644
- ```
844
+ See the [Configuration](https://github.com/amaiya/patchpal?tab=readme-ov-file#configuration) section for all available `PATCHPAL_*` environment variables to customize security, permissions, logging, and more.
645
845
 
646
846
  **Permission System:**
647
847
 
@@ -717,20 +917,12 @@ You: /compact
717
917
  ```
718
918
 
719
919
  **Configuration:**
720
- ```bash
721
- # Disable auto-compaction (not recommended for long sessions)
722
- export PATCHPAL_DISABLE_AUTOCOMPACT=true
723
-
724
- # Adjust compaction threshold (default: 0.85 = 85%)
725
- export PATCHPAL_COMPACT_THRESHOLD=0.90
726
920
 
727
- # Adjust pruning thresholds
728
- export PATCHPAL_PRUNE_PROTECT=40000 # Keep last 40k tokens (default)
729
- export PATCHPAL_PRUNE_MINIMUM=20000 # Min tokens to prune (default)
730
-
731
- # Override context limit for testing (useful for testing compaction with small values)
732
- export PATCHPAL_CONTEXT_LIMIT=10000 # Force 10k token limit instead of model default
733
- ```
921
+ See the [Configuration](https://github.com/amaiya/patchpal?tab=readme-ov-file#configuration) section for context management settings including:
922
+ - `PATCHPAL_DISABLE_AUTOCOMPACT` - Disable auto-compaction
923
+ - `PATCHPAL_COMPACT_THRESHOLD` - Adjust compaction threshold
924
+ - `PATCHPAL_CONTEXT_LIMIT` - Override context limit for testing
925
+ - `PATCHPAL_PRUNE_PROTECT` / `PATCHPAL_PRUNE_MINIMUM` - Pruning controls
734
926
 
735
927
  **Testing Context Management:**
736
928
 
@@ -802,10 +994,11 @@ The system ensures you can work for extended periods without hitting context lim
802
994
 
803
995
  **Error: "maximum iterations reached"**
804
996
  - The default number of iterations is 100.
805
- - You can increase by setting the environment variable, `export PATCHPAL_MAX_ITERATIONS`
997
+ - Increase with `export PATCHPAL_MAX_ITERATIONS=200` (see [Configuration](https://github.com/amaiya/patchpal?tab=readme-ov-file#configuration))
806
998
 
807
999
  **Error: "Context Window Error - Input is too long"**
808
1000
  - PatchPal includes automatic context management (compaction) to prevent this error.
809
1001
  - Use `/status` to check your context window usage.
810
1002
  - If auto-compaction is disabled, re-enable it: `unset PATCHPAL_DISABLE_AUTOCOMPACT`
811
1003
  - Context is automatically managed at 85% capacity through pruning and compaction.
1004
+ - See [Configuration](https://github.com/amaiya/patchpal?tab=readme-ov-file#configuration) for context management settings.