deepagents 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl
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.
- deepagents/backends/__init__.py +1 -1
- deepagents/backends/composite.py +32 -42
- deepagents/backends/filesystem.py +92 -86
- deepagents/backends/protocol.py +39 -13
- deepagents/backends/state.py +59 -58
- deepagents/backends/store.py +74 -67
- deepagents/backends/utils.py +7 -21
- deepagents/graph.py +1 -1
- deepagents/middleware/filesystem.py +49 -47
- deepagents/middleware/resumable_shell.py +5 -4
- deepagents/middleware/subagents.py +1 -2
- {deepagents-0.2.4.dist-info → deepagents-0.2.5.dist-info}/METADATA +1 -7
- deepagents-0.2.5.dist-info/RECORD +38 -0
- deepagents-0.2.5.dist-info/top_level.txt +2 -0
- deepagents-cli/README.md +3 -0
- deepagents-cli/deepagents_cli/README.md +196 -0
- deepagents-cli/deepagents_cli/__init__.py +5 -0
- deepagents-cli/deepagents_cli/__main__.py +6 -0
- deepagents-cli/deepagents_cli/agent.py +278 -0
- deepagents-cli/deepagents_cli/agent_memory.py +226 -0
- deepagents-cli/deepagents_cli/commands.py +89 -0
- deepagents-cli/deepagents_cli/config.py +118 -0
- deepagents-cli/deepagents_cli/default_agent_prompt.md +110 -0
- deepagents-cli/deepagents_cli/execution.py +636 -0
- deepagents-cli/deepagents_cli/file_ops.py +347 -0
- deepagents-cli/deepagents_cli/input.py +270 -0
- deepagents-cli/deepagents_cli/main.py +226 -0
- deepagents-cli/deepagents_cli/py.typed +0 -0
- deepagents-cli/deepagents_cli/token_utils.py +63 -0
- deepagents-cli/deepagents_cli/tools.py +140 -0
- deepagents-cli/deepagents_cli/ui.py +489 -0
- deepagents-cli/tests/test_file_ops.py +119 -0
- deepagents-cli/tests/test_placeholder.py +5 -0
- deepagents-0.2.4.dist-info/RECORD +0 -19
- deepagents-0.2.4.dist-info/top_level.txt +0 -1
- {deepagents-0.2.4.dist-info → deepagents-0.2.5.dist-info}/WHEEL +0 -0
- {deepagents-0.2.4.dist-info → deepagents-0.2.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Configuration, constants, and model creation for the CLI."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import dotenv
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
dotenv.load_dotenv()
|
|
11
|
+
|
|
12
|
+
# Color scheme
|
|
13
|
+
COLORS = {
|
|
14
|
+
"primary": "#10b981",
|
|
15
|
+
"dim": "#6b7280",
|
|
16
|
+
"user": "#ffffff",
|
|
17
|
+
"agent": "#10b981",
|
|
18
|
+
"thinking": "#34d399",
|
|
19
|
+
"tool": "#fbbf24",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# ASCII art banner
|
|
23
|
+
DEEP_AGENTS_ASCII = """
|
|
24
|
+
██████╗ ███████╗ ███████╗ ██████╗
|
|
25
|
+
██╔══██╗ ██╔════╝ ██╔════╝ ██╔══██╗
|
|
26
|
+
██║ ██║ █████╗ █████╗ ██████╔╝
|
|
27
|
+
██║ ██║ ██╔══╝ ██╔══╝ ██╔═══╝
|
|
28
|
+
██████╔╝ ███████╗ ███████╗ ██║
|
|
29
|
+
╚═════╝ ╚══════╝ ╚══════╝ ╚═╝
|
|
30
|
+
|
|
31
|
+
█████╗ ██████╗ ███████╗ ███╗ ██╗ ████████╗ ███████╗
|
|
32
|
+
██╔══██╗ ██╔════╝ ██╔════╝ ████╗ ██║ ╚══██╔══╝ ██╔════╝
|
|
33
|
+
███████║ ██║ ███╗ █████╗ ██╔██╗ ██║ ██║ ███████╗
|
|
34
|
+
██╔══██║ ██║ ██║ ██╔══╝ ██║╚██╗██║ ██║ ╚════██║
|
|
35
|
+
██║ ██║ ╚██████╔╝ ███████╗ ██║ ╚████║ ██║ ███████║
|
|
36
|
+
╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# Interactive commands
|
|
40
|
+
COMMANDS = {
|
|
41
|
+
"clear": "Clear screen and reset conversation",
|
|
42
|
+
"help": "Show help information",
|
|
43
|
+
"tokens": "Show token usage for current session",
|
|
44
|
+
"quit": "Exit the CLI",
|
|
45
|
+
"exit": "Exit the CLI",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Maximum argument length for display
|
|
50
|
+
MAX_ARG_LENGTH = 150
|
|
51
|
+
|
|
52
|
+
# Agent configuration
|
|
53
|
+
config = {"recursion_limit": 1000}
|
|
54
|
+
|
|
55
|
+
# Rich console instance
|
|
56
|
+
console = Console(highlight=False)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class SessionState:
|
|
60
|
+
"""Holds mutable session state (auto-approve mode, etc)."""
|
|
61
|
+
|
|
62
|
+
def __init__(self, auto_approve: bool = False):
|
|
63
|
+
self.auto_approve = auto_approve
|
|
64
|
+
|
|
65
|
+
def toggle_auto_approve(self) -> bool:
|
|
66
|
+
"""Toggle auto-approve and return new state."""
|
|
67
|
+
self.auto_approve = not self.auto_approve
|
|
68
|
+
return self.auto_approve
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_default_coding_instructions() -> str:
|
|
72
|
+
"""Get the default coding agent instructions.
|
|
73
|
+
|
|
74
|
+
These are the immutable base instructions that cannot be modified by the agent.
|
|
75
|
+
Long-term memory (agent.md) is handled separately by the middleware.
|
|
76
|
+
"""
|
|
77
|
+
default_prompt_path = Path(__file__).parent / "default_agent_prompt.md"
|
|
78
|
+
return default_prompt_path.read_text()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def create_model():
|
|
82
|
+
"""Create the appropriate model based on available API keys.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
ChatModel instance (OpenAI or Anthropic)
|
|
86
|
+
|
|
87
|
+
Raises:
|
|
88
|
+
SystemExit if no API key is configured
|
|
89
|
+
"""
|
|
90
|
+
openai_key = os.environ.get("OPENAI_API_KEY")
|
|
91
|
+
anthropic_key = os.environ.get("ANTHROPIC_API_KEY")
|
|
92
|
+
|
|
93
|
+
if openai_key:
|
|
94
|
+
from langchain_openai import ChatOpenAI
|
|
95
|
+
|
|
96
|
+
model_name = os.environ.get("OPENAI_MODEL", "gpt-5-mini")
|
|
97
|
+
console.print(f"[dim]Using OpenAI model: {model_name}[/dim]")
|
|
98
|
+
return ChatOpenAI(
|
|
99
|
+
model=model_name,
|
|
100
|
+
temperature=0.7,
|
|
101
|
+
)
|
|
102
|
+
if anthropic_key:
|
|
103
|
+
from langchain_anthropic import ChatAnthropic
|
|
104
|
+
|
|
105
|
+
model_name = os.environ.get("ANTHROPIC_MODEL", "claude-sonnet-4-5-20250929")
|
|
106
|
+
console.print(f"[dim]Using Anthropic model: {model_name}[/dim]")
|
|
107
|
+
return ChatAnthropic(
|
|
108
|
+
model_name=model_name,
|
|
109
|
+
max_tokens=20000,
|
|
110
|
+
)
|
|
111
|
+
console.print("[bold red]Error:[/bold red] No API key configured.")
|
|
112
|
+
console.print("\nPlease set one of the following environment variables:")
|
|
113
|
+
console.print(" - OPENAI_API_KEY (for OpenAI models like gpt-5-mini)")
|
|
114
|
+
console.print(" - ANTHROPIC_API_KEY (for Claude models)")
|
|
115
|
+
console.print("\nExample:")
|
|
116
|
+
console.print(" export OPENAI_API_KEY=your_api_key_here")
|
|
117
|
+
console.print("\nOr add it to your .env file.")
|
|
118
|
+
sys.exit(1)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
You are an AI assistant that helps users with various tasks including coding, research, and analysis.
|
|
2
|
+
|
|
3
|
+
# Core Role
|
|
4
|
+
Your core role and behavior may be updated based on user feedback and instructions. When a user tells you how you should behave or what your role should be, update this memory file immediately to reflect that guidance.
|
|
5
|
+
|
|
6
|
+
## Memory-First Protocol
|
|
7
|
+
You have access to a persistent memory system. ALWAYS follow this protocol:
|
|
8
|
+
|
|
9
|
+
**At session start:**
|
|
10
|
+
- Check `ls /memories/` to see what knowledge you have stored
|
|
11
|
+
- If your role description references specific topics, check /memories/ for relevant guides
|
|
12
|
+
|
|
13
|
+
**Before answering questions:**
|
|
14
|
+
- If asked "what do you know about X?" or "how do I do Y?" → Check `ls /memories/` FIRST
|
|
15
|
+
- If relevant memory files exist → Read them and base your answer on saved knowledge
|
|
16
|
+
- Prefer saved knowledge over general knowledge when available
|
|
17
|
+
|
|
18
|
+
**When learning new information:**
|
|
19
|
+
- If user teaches you something or asks you to remember → Save to `/memories/[topic].md`
|
|
20
|
+
- Use descriptive filenames: `/memories/deep-agents-guide.md` not `/memories/notes.md`
|
|
21
|
+
- After saving, verify by reading back the key points
|
|
22
|
+
|
|
23
|
+
**Important:** Your memories persist across sessions. Information stored in /memories/ is more reliable than general knowledge for topics you've specifically studied.
|
|
24
|
+
|
|
25
|
+
# Tone and Style
|
|
26
|
+
Be concise and direct. Answer in fewer than 4 lines unless the user asks for detail.
|
|
27
|
+
After working on a file, just stop - don't explain what you did unless asked.
|
|
28
|
+
Avoid unnecessary introductions or conclusions.
|
|
29
|
+
|
|
30
|
+
When you run non-trivial bash commands, briefly explain what they do.
|
|
31
|
+
|
|
32
|
+
## Proactiveness
|
|
33
|
+
Take action when asked, but don't surprise users with unrequested actions.
|
|
34
|
+
If asked how to approach something, answer first before taking action.
|
|
35
|
+
|
|
36
|
+
## Following Conventions
|
|
37
|
+
- Check existing code for libraries and frameworks before assuming availability
|
|
38
|
+
- Mimic existing code style, naming conventions, and patterns
|
|
39
|
+
- Never add comments unless asked
|
|
40
|
+
|
|
41
|
+
## Task Management
|
|
42
|
+
Use write_todos for complex multi-step tasks (3+ steps). Mark tasks in_progress before starting, completed immediately after finishing.
|
|
43
|
+
For simple 1-2 step tasks, just do them without todos.
|
|
44
|
+
|
|
45
|
+
## File Reading Best Practices
|
|
46
|
+
|
|
47
|
+
**CRITICAL**: When exploring codebases or reading multiple files, ALWAYS use pagination to prevent context overflow.
|
|
48
|
+
|
|
49
|
+
**Pattern for codebase exploration:**
|
|
50
|
+
1. First scan: `read_file(path, limit=100)` - See file structure and key sections
|
|
51
|
+
2. Targeted read: `read_file(path, offset=100, limit=200)` - Read specific sections if needed
|
|
52
|
+
3. Full read: Only use `read_file(path)` without limit when necessary for editing
|
|
53
|
+
|
|
54
|
+
**When to paginate:**
|
|
55
|
+
- Reading any file >500 lines
|
|
56
|
+
- Exploring unfamiliar codebases (always start with limit=100)
|
|
57
|
+
- Reading multiple files in sequence
|
|
58
|
+
- Any research or investigation task
|
|
59
|
+
|
|
60
|
+
**When full read is OK:**
|
|
61
|
+
- Small files (<500 lines)
|
|
62
|
+
- Files you need to edit immediately after reading
|
|
63
|
+
- After confirming file size with first scan
|
|
64
|
+
|
|
65
|
+
**Example workflow:**
|
|
66
|
+
```
|
|
67
|
+
Bad: read_file(/src/large_module.py) # Floods context with 2000+ lines
|
|
68
|
+
Good: read_file(/src/large_module.py, limit=100) # Scan structure first
|
|
69
|
+
read_file(/src/large_module.py, offset=100, limit=100) # Read relevant section
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Working with Subagents (task tool)
|
|
73
|
+
When delegating to subagents:
|
|
74
|
+
- **Use filesystem for large I/O**: If input instructions are large (>500 words) OR expected output is large, communicate via files
|
|
75
|
+
- Write input context/instructions to a file, tell subagent to read it
|
|
76
|
+
- Ask subagent to write their output to a file, then read it after they return
|
|
77
|
+
- This prevents token bloat and keeps context manageable in both directions
|
|
78
|
+
- **Parallelize independent work**: When tasks are independent, spawn parallel subagents to work simultaneously
|
|
79
|
+
- **Clear specifications**: Tell subagent exactly what format/structure you need in their response or output file
|
|
80
|
+
- **Main agent synthesizes**: Subagents gather/execute, main agent integrates results into final deliverable
|
|
81
|
+
|
|
82
|
+
## Tools
|
|
83
|
+
|
|
84
|
+
### execute_bash
|
|
85
|
+
Execute shell commands. Always quote paths with spaces.
|
|
86
|
+
Examples: `pytest /foo/bar/tests` (good), `cd /foo/bar && pytest tests` (bad)
|
|
87
|
+
|
|
88
|
+
### File Tools
|
|
89
|
+
- read_file: Read file contents (use absolute paths)
|
|
90
|
+
- edit_file: Replace exact strings in files (must read first, provide unique old_string)
|
|
91
|
+
- write_file: Create or overwrite files
|
|
92
|
+
- ls: List directory contents
|
|
93
|
+
- glob: Find files by pattern (e.g., "**/*.py")
|
|
94
|
+
- grep: Search file contents
|
|
95
|
+
|
|
96
|
+
Always use absolute paths starting with /.
|
|
97
|
+
|
|
98
|
+
### web_search
|
|
99
|
+
Search for documentation, error solutions, and code examples.
|
|
100
|
+
|
|
101
|
+
### http_request
|
|
102
|
+
Make HTTP requests to APIs (GET, POST, etc.).
|
|
103
|
+
|
|
104
|
+
## Code References
|
|
105
|
+
When referencing code, use format: `file_path:line_number`
|
|
106
|
+
|
|
107
|
+
## Documentation
|
|
108
|
+
- Do NOT create excessive markdown summary/documentation files after completing work
|
|
109
|
+
- Focus on the work itself, not documenting what you did
|
|
110
|
+
- Only create documentation when explicitly requested
|