Skip to content

Commit 5f34d37

Browse files
authored
Merge pull request #591 from srtab/feat/repository-ctx-rename
Renamed RepositoryCtx to RuntimeCtx.
2 parents 7164a2c + 4b7491b commit 5f34d37

File tree

24 files changed

+128
-172
lines changed

24 files changed

+128
-172
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
DAIV is an open-source automation assistant designed to enhance developer productivity. It integrates seamlessly with **GitLab** and **GitHub** repositories to streamline your development process. It uses AI agents and configurable actions to automate common software development tasks such as:
88

99
- **Issue Addressing**: Planning and, after human approval, executing solutions directly from issue titles and descriptions.
10-
- **Code Review Assistance**: Automatically responding to reviewer comments, adjusting code, and improving pull requests on demand.
11-
- **Pipeline Fixer**: Repairing failed CI/CD pipeline jobs by suggesting fixes and applying them after human approval.
10+
- **Code Review Assistance**: Automatically responding to reviewer comments, adjusting code, repairing failed CI/CD pipelines and improving pull requests on demand.
1211

1312
## Key Features
1413

@@ -135,7 +134,7 @@ DAIV is an open-source automation assistant designed to enhance developer produc
135134
136135
- [x] 🐙 Add support to GitHub.
137136
- [x] 🤖 Add support to [AGENTS.md](https://agents.md/) format to guide agents.
138-
- [x] 🌐 Add support to custom MCP servers.
137+
- [ ] 🌐 Add support to custom MCP servers.
139138
- [x] 📊 Add an evaluation system to measure the quality of DAIV's agents.
140139
- [ ] 🔍 Add support to automated code review.
141140
- [ ] 🎨 Create a frontend to DAIV initial setup and configuration, dashboard with some metrics, a chat interface to interact with DAIV...

daiv/automation/agents/codebase_chat/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from automation.agents import BaseAgent, ThinkingLevel
1212
from automation.agents.tools.toolkits import FileNavigationToolkit
13-
from codebase.context import get_repository_ctx
13+
from codebase.context import get_runtime_ctx
1414

1515
from .conf import settings
1616
from .prompts import codebase_chat_system
@@ -20,7 +20,7 @@ class CodebaseChatAgent(BaseAgent[CompiledStateGraph]):
2020
"""
2121
Agent for answering questions about specific repository.
2222
23-
Use `set_repository_ctx` to set the repository context before using this agent.
23+
Use `set_runtime_ctx` to set the runtime context before using this agent.
2424
"""
2525

2626
async def compile(self) -> CompiledStateGraph:
@@ -37,7 +37,7 @@ async def compile(self) -> CompiledStateGraph:
3737
tools=FileNavigationToolkit.get_tools(),
3838
store=InMemoryStore(),
3939
prompt=ChatPromptTemplate.from_messages([codebase_chat_system, MessagesPlaceholder("messages")]).partial(
40-
current_date_time=timezone.now().strftime("%d %B, %Y"), repository=get_repository_ctx().repo_id
40+
current_date_time=timezone.now().strftime("%d %B, %Y"), repository=get_runtime_ctx().repo_id
4141
),
4242
name=settings.NAME,
4343
).with_config(RunnableConfig(recursion_limit=settings.RECURSION_LIMIT))

daiv/automation/agents/nodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING
66

77
from automation.agents.tools.sandbox import bash_tool
8-
from codebase.context import get_repository_ctx
8+
from codebase.context import get_runtime_ctx
99

1010
if TYPE_CHECKING:
1111
from langgraph.store.base import BaseStore
@@ -23,7 +23,7 @@ async def apply_format_code_node(store: BaseStore) -> str | None:
2323
Returns:
2424
str | None: The output of the last command, or None if format code is disabled.
2525
"""
26-
ctx = get_repository_ctx()
26+
ctx = get_runtime_ctx()
2727

2828
if not ctx.config.sandbox.enabled or not ctx.config.sandbox.format_code:
2929
logger.info("Format code is disabled for this repository, skipping.")

daiv/automation/agents/plan_and_execute/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030
from automation.agents.utils import extract_images_from_text
3131
from automation.utils import has_file_changes
32-
from codebase.context import get_repository_ctx
32+
from codebase.context import get_runtime_ctx
3333
from core.constants import BOT_LABEL, BOT_NAME
3434

3535
from .conf import settings
@@ -185,7 +185,7 @@ def __init__(
185185
self.plan_system_template = plan_system_template or plan_system
186186
self.skip_approval = skip_approval
187187
self.skip_format_code = skip_format_code
188-
self.ctx = get_repository_ctx()
188+
self.ctx = get_runtime_ctx()
189189
super().__init__(**kwargs)
190190

191191
async def compile(self) -> CompiledStateGraph:

daiv/automation/agents/review_addressor/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from automation.agents.plan_and_execute import PlanAndExecuteAgent
1818
from automation.agents.tools.toolkits import FileNavigationToolkit, MergeRequestToolkit, WebSearchToolkit
1919
from codebase.clients import RepoClient
20-
from codebase.context import get_repository_ctx
20+
from codebase.context import get_runtime_ctx
2121
from core.constants import BOT_NAME
2222

2323
from .conf import settings
@@ -48,7 +48,7 @@ class ReplyReviewerAgent(BaseAgent[CompiledStateGraph]):
4848
"""
4949

5050
async def compile(self) -> CompiledStateGraph:
51-
ctx = get_repository_ctx()
51+
ctx = get_runtime_ctx()
5252

5353
tools = FileNavigationToolkit.get_tools() + WebSearchToolkit.get_tools() + MergeRequestToolkit.get_tools()
5454

daiv/automation/agents/schemas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from codebase.base import ClientType
1010
from codebase.clients import RepoClient
11-
from codebase.context import get_repository_ctx
11+
from codebase.context import get_runtime_ctx
1212
from core.utils import extract_valid_image_mimetype, is_valid_url
1313

1414

@@ -35,7 +35,7 @@ async def from_images(images: list[Image]) -> list[ImageTemplate]:
3535
Returns:
3636
list[ImageTemplate]: The list of image templates.
3737
"""
38-
ctx = get_repository_ctx()
38+
ctx = get_runtime_ctx()
3939
repo_client = RepoClient.create_instance()
4040
image_templates = []
4141

daiv/automation/agents/tools/editing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from automation.agents.utils import find_original_snippet
1010
from automation.utils import check_file_read, get_file_change, get_file_changes, register_file_change
1111
from codebase.base import FileChangeAction
12-
from codebase.context import get_repository_ctx
12+
from codebase.context import get_runtime_ctx
1313

1414
logger = logging.getLogger("daiv.tools")
1515

@@ -51,7 +51,7 @@ async def edit_tool(
5151
""" # noqa: E501
5252
logger.debug("[%s] Editing file '%s'", edit_tool.name, file_path)
5353

54-
ctx = get_repository_ctx()
54+
ctx = get_runtime_ctx()
5555
resolved_file_path = (ctx.repo_dir / file_path).resolve()
5656

5757
if not resolved_file_path.exists() or not resolved_file_path.is_file():
@@ -121,7 +121,7 @@ async def write_tool(file_path: str, content: str, store: Annotated[Any, Injecte
121121
""" # noqa: E501
122122
logger.debug("[%s] Writing to file '%s'", write_tool.name, file_path)
123123

124-
ctx = get_repository_ctx()
124+
ctx = get_runtime_ctx()
125125
resolved_file_path = (ctx.repo_dir / file_path).resolve()
126126
file_exists = resolved_file_path.exists()
127127

@@ -171,7 +171,7 @@ async def delete_tool(file_path: str, store: Annotated[Any, InjectedStore()] = N
171171
""" # noqa: E501
172172
logger.debug("[%s] Deleting file '%s'", delete_tool.name, file_path)
173173

174-
ctx = get_repository_ctx()
174+
ctx = get_runtime_ctx()
175175
resolved_file_path = (ctx.repo_dir / file_path).resolve()
176176

177177
if not resolved_file_path.exists() or not resolved_file_path.is_file():
@@ -221,7 +221,7 @@ async def rename_tool(file_path: str, new_file_path: str, store: Annotated[Any,
221221
""" # noqa: E501
222222
logger.debug("[%s] Renaming file '%s' to '%s'", rename_tool.name, file_path, new_file_path)
223223

224-
ctx = get_repository_ctx()
224+
ctx = get_runtime_ctx()
225225

226226
resolved_file_path = (ctx.repo_dir / file_path).resolve()
227227
resolved_new_file_path = (ctx.repo_dir / new_file_path).resolve()

daiv/automation/agents/tools/merge_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from codebase.clients import RepoClient
99
from codebase.clients.utils import clean_job_logs
10-
from codebase.context import get_repository_ctx
10+
from codebase.context import get_runtime_ctx
1111

1212
logger = logging.getLogger("daiv.tools")
1313

@@ -35,7 +35,7 @@ def pipeline_tool(placeholder: str = "") -> str:
3535
Returns:
3636
str: JSON formatted pipeline/workflow information including status and job details.
3737
"""
38-
ctx = get_repository_ctx()
38+
ctx = get_runtime_ctx()
3939

4040
logger.debug("[%s] Getting pipeline for merge request %d", pipeline_tool.name, ctx.merge_request_id)
4141

@@ -120,7 +120,7 @@ def job_logs_tool(job_id: int, offset_from_end: int = 0, line_count: int = JOB_L
120120
offset_from_end,
121121
)
122122

123-
ctx = get_repository_ctx()
123+
ctx = get_runtime_ctx()
124124
client = RepoClient.create_instance()
125125

126126
# Get job details to determine status

daiv/automation/agents/tools/navigation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from automation.agents.schemas import ImageTemplate
1515
from automation.utils import register_file_read
16-
from codebase.context import get_repository_ctx
16+
from codebase.context import get_runtime_ctx
1717
from core.utils import extract_valid_image_mimetype
1818

1919
logger = logging.getLogger("daiv.tools")
@@ -47,7 +47,7 @@ def glob_tool(pattern: str, path: str | None = None) -> str:
4747
""" # noqa: E501
4848
logger.debug("[%s] Finding files matching '%s' in %s", glob_tool.name, pattern, path or "repository root")
4949

50-
ctx = get_repository_ctx()
50+
ctx = get_runtime_ctx()
5151

5252
root = ctx.repo_dir if path is None else (ctx.repo_dir / path).resolve()
5353

@@ -116,7 +116,7 @@ def grep_tool(pattern: str, path: str | None = None, include: str | None = None)
116116
include,
117117
)
118118

119-
ctx = get_repository_ctx()
119+
ctx = get_runtime_ctx()
120120

121121
root = ctx.repo_dir if path is None else (ctx.repo_dir / path).resolve()
122122

@@ -151,7 +151,7 @@ def ls_tool(path: str) -> str:
151151
""" # noqa: E501
152152
logger.debug("[%s] Listing files in %s", ls_tool.name, path)
153153

154-
ctx = get_repository_ctx()
154+
ctx = get_runtime_ctx()
155155

156156
root = (ctx.repo_dir / path).resolve()
157157

@@ -193,7 +193,7 @@ async def read_tool(file_path: str, store: Annotated[Any, InjectedStore()] = Non
193193
""" # noqa: E501
194194
logger.debug("[%s] Reading file '%s'", read_tool.name, file_path)
195195

196-
ctx = get_repository_ctx()
196+
ctx = get_runtime_ctx()
197197
resolved_file_path = (ctx.repo_dir / file_path).resolve()
198198

199199
if (

daiv/automation/agents/tools/sandbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from automation.utils import register_file_change
1717
from codebase.base import FileChangeAction
18-
from codebase.context import get_repository_ctx
18+
from codebase.context import get_runtime_ctx
1919
from core.conf import settings
2020
from core.sandbox import run_sandbox_commands, start_sandbox_session
2121
from core.sandbox.schemas import RunCommandResult, RunCommandsRequest, StartSessionRequest
@@ -132,7 +132,7 @@ async def bash_tool(commands: list[str], store: Annotated[Any, InjectedStore()])
132132

133133
assert settings.SANDBOX_API_KEY is not None, "SANDBOX_API_KEY is not set"
134134

135-
ctx = get_repository_ctx()
135+
ctx = get_runtime_ctx()
136136

137137
# Start the sandbox session to ensure that the sandbox session is started before running the commands.
138138
# If the sandbox session already exists in the store, it will be reused.

0 commit comments

Comments
 (0)