diagram-to-iac 0.7.0__py3-none-any.whl → 0.8.0__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.
- diagram_to_iac/__init__.py +10 -0
- diagram_to_iac/actions/__init__.py +7 -0
- diagram_to_iac/actions/git_entry.py +174 -0
- diagram_to_iac/actions/supervisor_entry.py +116 -0
- diagram_to_iac/actions/terraform_agent_entry.py +207 -0
- diagram_to_iac/agents/__init__.py +26 -0
- diagram_to_iac/agents/demonstrator_langgraph/__init__.py +10 -0
- diagram_to_iac/agents/demonstrator_langgraph/agent.py +826 -0
- diagram_to_iac/agents/git_langgraph/__init__.py +10 -0
- diagram_to_iac/agents/git_langgraph/agent.py +1018 -0
- diagram_to_iac/agents/git_langgraph/pr.py +146 -0
- diagram_to_iac/agents/hello_langgraph/__init__.py +9 -0
- diagram_to_iac/agents/hello_langgraph/agent.py +621 -0
- diagram_to_iac/agents/policy_agent/__init__.py +15 -0
- diagram_to_iac/agents/policy_agent/agent.py +507 -0
- diagram_to_iac/agents/policy_agent/integration_example.py +191 -0
- diagram_to_iac/agents/policy_agent/tools/__init__.py +14 -0
- diagram_to_iac/agents/policy_agent/tools/tfsec_tool.py +259 -0
- diagram_to_iac/agents/shell_langgraph/__init__.py +21 -0
- diagram_to_iac/agents/shell_langgraph/agent.py +122 -0
- diagram_to_iac/agents/shell_langgraph/detector.py +50 -0
- diagram_to_iac/agents/supervisor_langgraph/__init__.py +17 -0
- diagram_to_iac/agents/supervisor_langgraph/agent.py +1947 -0
- diagram_to_iac/agents/supervisor_langgraph/demonstrator.py +22 -0
- diagram_to_iac/agents/supervisor_langgraph/guards.py +23 -0
- diagram_to_iac/agents/supervisor_langgraph/pat_loop.py +49 -0
- diagram_to_iac/agents/supervisor_langgraph/router.py +9 -0
- diagram_to_iac/agents/terraform_langgraph/__init__.py +15 -0
- diagram_to_iac/agents/terraform_langgraph/agent.py +1216 -0
- diagram_to_iac/agents/terraform_langgraph/parser.py +76 -0
- diagram_to_iac/core/__init__.py +7 -0
- diagram_to_iac/core/agent_base.py +19 -0
- diagram_to_iac/core/enhanced_memory.py +302 -0
- diagram_to_iac/core/errors.py +4 -0
- diagram_to_iac/core/issue_tracker.py +49 -0
- diagram_to_iac/core/memory.py +132 -0
- diagram_to_iac/services/__init__.py +10 -0
- diagram_to_iac/services/observability.py +59 -0
- diagram_to_iac/services/step_summary.py +77 -0
- diagram_to_iac/tools/__init__.py +11 -0
- diagram_to_iac/tools/api_utils.py +108 -26
- diagram_to_iac/tools/git/__init__.py +45 -0
- diagram_to_iac/tools/git/git.py +956 -0
- diagram_to_iac/tools/hello/__init__.py +30 -0
- diagram_to_iac/tools/hello/cal_utils.py +31 -0
- diagram_to_iac/tools/hello/text_utils.py +97 -0
- diagram_to_iac/tools/llm_utils/__init__.py +20 -0
- diagram_to_iac/tools/llm_utils/anthropic_driver.py +87 -0
- diagram_to_iac/tools/llm_utils/base_driver.py +90 -0
- diagram_to_iac/tools/llm_utils/gemini_driver.py +89 -0
- diagram_to_iac/tools/llm_utils/openai_driver.py +93 -0
- diagram_to_iac/tools/llm_utils/router.py +303 -0
- diagram_to_iac/tools/sec_utils.py +4 -2
- diagram_to_iac/tools/shell/__init__.py +17 -0
- diagram_to_iac/tools/shell/shell.py +415 -0
- diagram_to_iac/tools/text_utils.py +277 -0
- diagram_to_iac/tools/tf/terraform.py +851 -0
- diagram_to_iac-0.8.0.dist-info/METADATA +99 -0
- diagram_to_iac-0.8.0.dist-info/RECORD +64 -0
- {diagram_to_iac-0.7.0.dist-info → diagram_to_iac-0.8.0.dist-info}/WHEEL +1 -1
- diagram_to_iac-0.8.0.dist-info/entry_points.txt +4 -0
- diagram_to_iac/agents/codegen_agent.py +0 -0
- diagram_to_iac/agents/consensus_agent.py +0 -0
- diagram_to_iac/agents/deployment_agent.py +0 -0
- diagram_to_iac/agents/github_agent.py +0 -0
- diagram_to_iac/agents/interpretation_agent.py +0 -0
- diagram_to_iac/agents/question_agent.py +0 -0
- diagram_to_iac/agents/supervisor.py +0 -0
- diagram_to_iac/agents/vision_agent.py +0 -0
- diagram_to_iac/core/config.py +0 -0
- diagram_to_iac/tools/cv_utils.py +0 -0
- diagram_to_iac/tools/gh_utils.py +0 -0
- diagram_to_iac/tools/tf_utils.py +0 -0
- diagram_to_iac-0.7.0.dist-info/METADATA +0 -16
- diagram_to_iac-0.7.0.dist-info/RECORD +0 -32
- diagram_to_iac-0.7.0.dist-info/entry_points.txt +0 -2
- {diagram_to_iac-0.7.0.dist-info → diagram_to_iac-0.8.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
# src/diagram_to_iac/agents/git_langgraph/pr.py
|
2
|
+
import git
|
3
|
+
import os
|
4
|
+
|
5
|
+
class GitPrCreator:
|
6
|
+
def __init__(self, repo_path: str, remote_name: str = "origin", copilot_assignee: str = None, default_assignees: list = None):
|
7
|
+
self.repo_path = repo_path
|
8
|
+
self.remote_name = remote_name
|
9
|
+
self.copilot_assignee = copilot_assignee
|
10
|
+
self.default_assignees = default_assignees if default_assignees else []
|
11
|
+
try:
|
12
|
+
self.repo = git.Repo(self.repo_path)
|
13
|
+
except git.exc.InvalidGitRepositoryError:
|
14
|
+
print(f"Warning: {self.repo_path} is not a valid git repository.")
|
15
|
+
self.repo = None
|
16
|
+
except Exception as e:
|
17
|
+
print(f"An unexpected error occurred during GitPrCreator initialization: {e}")
|
18
|
+
self.repo = None
|
19
|
+
|
20
|
+
|
21
|
+
def create_draft_pr(self, error_type: str, title: str, body: str):
|
22
|
+
if not self.repo:
|
23
|
+
print(f"Error: Git repository not initialized at {self.repo_path}. Cannot create PR.")
|
24
|
+
return {"status": "error", "message": "Git repository not initialized", "branch_name": None, "pr_url": None, "title": title, "body": body, "assignees": []}
|
25
|
+
|
26
|
+
branch_name = f"feature/auto-fix-{error_type}"
|
27
|
+
original_branch_name = "Unknown"
|
28
|
+
|
29
|
+
try:
|
30
|
+
# Store the original branch name
|
31
|
+
if not self.repo.head.is_detached:
|
32
|
+
original_branch_name = self.repo.active_branch.name
|
33
|
+
else:
|
34
|
+
# If HEAD is detached, decide on a fallback strategy.
|
35
|
+
# For now, we'll attempt to use 'main' or 'master' if they exist, otherwise error out or use a default.
|
36
|
+
# This part might need more sophisticated logic depending on desired behavior.
|
37
|
+
print("Warning: HEAD is detached. Attempting to find a default branch (main/master) to return to.")
|
38
|
+
found_default = False
|
39
|
+
for default_name in ['main', 'master']:
|
40
|
+
if default_name in self.repo.heads:
|
41
|
+
original_branch_name = default_name
|
42
|
+
found_default = True
|
43
|
+
break
|
44
|
+
if not found_default:
|
45
|
+
print("Error: HEAD is detached and could not determine a default branch to return to. PR creation will proceed but checkout back might fail.")
|
46
|
+
# original_branch_name will remain "Unknown" or could be set to a specific commit SHA if needed.
|
47
|
+
|
48
|
+
print(f"Original branch context: {original_branch_name}")
|
49
|
+
|
50
|
+
# Fetch from origin to have up-to-date refs
|
51
|
+
# Ensure remote 'origin' (or self.remote_name) exists
|
52
|
+
if self.remote_name in [remote.name for remote in self.repo.remotes]:
|
53
|
+
origin = self.repo.remote(name=self.remote_name)
|
54
|
+
print(f"Fetching from remote '{self.remote_name}'...")
|
55
|
+
origin.fetch()
|
56
|
+
else:
|
57
|
+
print(f"Warning: Remote '{self.remote_name}' not found. Skipping fetch.")
|
58
|
+
|
59
|
+
|
60
|
+
# Check if branch already exists, if so, check it out. Otherwise, create it.
|
61
|
+
if branch_name in self.repo.heads:
|
62
|
+
print(f"Branch '{branch_name}' already exists. Checking it out.")
|
63
|
+
new_branch = self.repo.heads[branch_name]
|
64
|
+
else:
|
65
|
+
print(f"Creating new branch: '{branch_name}'")
|
66
|
+
new_branch = self.repo.create_head(branch_name)
|
67
|
+
|
68
|
+
new_branch.checkout()
|
69
|
+
print(f"Checked out branch: {new_branch.name}")
|
70
|
+
|
71
|
+
# Stage changes and commit
|
72
|
+
if self.repo.is_dirty(untracked_files=True):
|
73
|
+
self.repo.git.add(A=True)
|
74
|
+
commit_message = f"Auto-fix for {error_type}: {title}"
|
75
|
+
self.repo.index.commit(commit_message)
|
76
|
+
print(f"Committed changes with message: '{commit_message}'")
|
77
|
+
else:
|
78
|
+
commit_message = f"Initial commit for auto-fix branch {error_type}: {title}"
|
79
|
+
self.repo.git.commit(m=commit_message, allow_empty=True)
|
80
|
+
print(f"Created an empty commit with message: '{commit_message}'")
|
81
|
+
|
82
|
+
# Push the new branch to the remote and set upstream
|
83
|
+
if self.remote_name in [remote.name for remote in self.repo.remotes]:
|
84
|
+
origin = self.repo.remote(name=self.remote_name)
|
85
|
+
print(f"Pushing branch {branch_name} to remote {self.remote_name} and setting upstream.")
|
86
|
+
self.repo.git.push('--set-upstream', origin.name, new_branch.name)
|
87
|
+
else:
|
88
|
+
print(f"Warning: Remote '{self.remote_name}' not found. Cannot push branch.")
|
89
|
+
# Depending on requirements, may want to error out here or proceed without push
|
90
|
+
# For now, we'll allow it to proceed and the PR URL will be local only.
|
91
|
+
|
92
|
+
|
93
|
+
# Determine assignee
|
94
|
+
assignees_to_set = []
|
95
|
+
if self.copilot_assignee: # Prioritize copilot_assignee
|
96
|
+
assignees_to_set.append(self.copilot_assignee)
|
97
|
+
elif self.default_assignees: # Fallback to default_assignees
|
98
|
+
assignees_to_set.extend(self.default_assignees)
|
99
|
+
|
100
|
+
assignee_text = f"Assignees: {', '.join(assignees_to_set)}" if assignees_to_set else "Assignees: None"
|
101
|
+
|
102
|
+
# Placeholder for creating the actual PR
|
103
|
+
pr_url = f"https://github.com/your-org/your-repo/pull/new/{branch_name}" # Example URL, adapt as needed
|
104
|
+
print(f"Branch {branch_name} pushed to {self.remote_name}.")
|
105
|
+
print(f"To create a Pull Request (manual step for now):")
|
106
|
+
print(f" URL: {pr_url}")
|
107
|
+
print(f" Title: {title}")
|
108
|
+
print(f" Body: {body}")
|
109
|
+
print(f" Base Branch: {original_branch_name if original_branch_name != 'Unknown' else 'your_default_branch'}") # Clarify base
|
110
|
+
print(assignee_text)
|
111
|
+
|
112
|
+
# Checkout back to original branch if it was known and not detached (or a known default)
|
113
|
+
if original_branch_name != "Unknown" and original_branch_name in self.repo.heads:
|
114
|
+
print(f"Checking out back to original branch: {original_branch_name}")
|
115
|
+
self.repo.git.checkout(original_branch_name)
|
116
|
+
elif not self.repo.head.is_detached:
|
117
|
+
# If original_branch_name was 'Unknown' but we are not detached, try to go back to active_branch before this method.
|
118
|
+
# This case should ideally not happen if original_branch_name is captured correctly.
|
119
|
+
print(f"Attempting to checkout back to the branch active before this operation: {self.repo.active_branch.name}")
|
120
|
+
# This might be risky if the active branch changed unexpectedly.
|
121
|
+
else:
|
122
|
+
print(f"Could not check out back to a specific branch (original was detached or unknown). Current branch: {self.repo.active_branch.name}")
|
123
|
+
|
124
|
+
|
125
|
+
return {"status": "success", "branch_name": branch_name, "pr_url": pr_url, "title": title, "body": body, "assignees": assignees_to_set}
|
126
|
+
|
127
|
+
except git.exc.GitCommandError as e:
|
128
|
+
print(f"Git command failed: {e}")
|
129
|
+
if original_branch_name != "Unknown" and original_branch_name in self.repo.heads:
|
130
|
+
try:
|
131
|
+
if self.repo.active_branch.name != original_branch_name:
|
132
|
+
self.repo.git.checkout(original_branch_name)
|
133
|
+
print(f"Checked out back to original branch: {original_branch_name} after GitCommandError.")
|
134
|
+
except Exception as ex_inner:
|
135
|
+
print(f"Failed to checkout back to {original_branch_name} after GitCommandError: {ex_inner}")
|
136
|
+
return {"status": "error", "message": str(e), "branch_name": branch_name, "pr_url": None, "title": title, "body": body, "assignees": []}
|
137
|
+
except Exception as e:
|
138
|
+
print(f"An unexpected error occurred: {e}")
|
139
|
+
if original_branch_name != "Unknown" and original_branch_name in self.repo.heads:
|
140
|
+
try:
|
141
|
+
if self.repo.active_branch.name != original_branch_name:
|
142
|
+
self.repo.git.checkout(original_branch_name)
|
143
|
+
print(f"Checked out back to original branch: {original_branch_name} after unexpected error.")
|
144
|
+
except Exception as ex_inner:
|
145
|
+
print(f"Failed to checkout back to {original_branch_name} after unexpected error: {ex_inner}")
|
146
|
+
return {"status": "error", "message": str(e), "branch_name": branch_name, "pr_url": None, "title": title, "body": body, "assignees": []}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"""
|
2
|
+
Hello LangGraph Agent Package
|
3
|
+
|
4
|
+
This package contains the HelloAgent implementation with its dedicated tools and configuration.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from .agent import HelloAgent, HelloAgentInput, HelloAgentOutput
|
8
|
+
|
9
|
+
__all__ = ["HelloAgent", "HelloAgentInput", "HelloAgentOutput"]
|