From f7eaf2238de0da5f54e8e84da0ce49891361bbf8 Mon Sep 17 00:00:00 2001 From: BrunoV21 Date: Tue, 9 Sep 2025 20:05:20 +0100 Subject: [PATCH 1/3] fix(ui): use diff syntax highlighting for patch outputs in UI and demo space --- codetide/agents/tide/ui/app.py | 2 +- examples/hf_demo_space/app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codetide/agents/tide/ui/app.py b/codetide/agents/tide/ui/app.py index 13c8b01..07e03cb 100644 --- a/codetide/agents/tide/ui/app.py +++ b/codetide/agents/tide/ui/app.py @@ -307,7 +307,7 @@ async def agent_loop(message: Optional[cl.Message]=None, codeIdentifiers: Option MarkerConfig( begin_marker="*** Begin Patch", end_marker="*** End Patch", - start_wrapper="\n```shell\n", + start_wrapper="\n```diff\n", end_wrapper="\n```\n", target_step=diff_step ), diff --git a/examples/hf_demo_space/app.py b/examples/hf_demo_space/app.py index feb5259..92e5c18 100644 --- a/examples/hf_demo_space/app.py +++ b/examples/hf_demo_space/app.py @@ -347,7 +347,7 @@ async def agent_loop(message: Optional[cl.Message]=None, codeIdentifiers: Option MarkerConfig( begin_marker="*** Begin Patch", end_marker="*** End Patch", - start_wrapper="\n```shell\n", + start_wrapper="\n```diff\n", end_wrapper="\n```\n", target_step=diff_step ), From c13001ceb25db8d7c8375073ee1a9b694f845b92 Mon Sep 17 00:00:00 2001 From: BrunoV21 Date: Tue, 9 Sep 2025 21:57:01 +0100 Subject: [PATCH 2/3] feat(mcp/tools): add smart code search tool for semantic codebase queries via MCP server --- codetide/mcp/tools/search_code.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 codetide/mcp/tools/search_code.py diff --git a/codetide/mcp/tools/search_code.py b/codetide/mcp/tools/search_code.py new file mode 100644 index 0000000..e0070b9 --- /dev/null +++ b/codetide/mcp/tools/search_code.py @@ -0,0 +1,32 @@ +import asyncio +from typing import List, Dict, Any +from codetide.mcp.server import codeTideMCPServer, initCodeTide +from codetide.search.code_search import SmartCodeSearch + +@codeTideMCPServer.tool( + name="searchCode", + description="Perform a smart search over the codebase. Returns the most relevant code files and elements for a given query." +) +async def search_code_tool(query: str, top_k: int = 10) -> List[Dict[str, Any]]: + """ + INSTRUCTION FOR AGENT: + Use this tool to perform a smart search over the codebase for any code-related query (e.g., function, class, or concept). + - Call this tool with a natural language search query and (optionally) the number of top results to return (default: 10). + - The tool will automatically initialize the codebase context. + - It returns a list of the most relevant code elements, each as a dictionary with: + - 'doc_key': the file path or identifier of the code element + - 'score': the relevance score + - 'context': a code snippet or summary for that result + - Use this tool when you need to locate where a concept, function, or class is defined or discussed in the codebase. + """ + tide = await initCodeTide() + nodes_dict = tide.codebase.compile_tree_nodes_dict() + documents = { + filepath: "\n".join([filepath] + elements).strip() + for filepath, elements in nodes_dict.items() + if (elements and len(elements) > 0) + } + code_search = SmartCodeSearch(documents=documents) + await code_search.initialize_async() + results = await code_search.search_with_context(query, top_k=top_k) + return results From 13471a915644747c8a493143b741479f35ab71c4 Mon Sep 17 00:00:00 2001 From: BrunoV21 Date: Tue, 9 Sep 2025 22:00:25 +0100 Subject: [PATCH 3/3] feat(agent): add additional command prompts and increase search results limit --- codetide/agents/tide/agent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/codetide/agents/tide/agent.py b/codetide/agents/tide/agent.py index 13e69b1..33ef190 100644 --- a/codetide/agents/tide/agent.py +++ b/codetide/agents/tide/agent.py @@ -6,7 +6,7 @@ from ...autocomplete import AutoComplete from .models import Steps from .prompts import ( - AGENT_TIDE_SYSTEM_PROMPT, CALMNESS_SYSTEM_PROMPT, GET_CODE_IDENTIFIERS_SYSTEM_PROMPT, README_CONTEXT_PROMPT, REJECT_PATCH_FEEDBACK_TEMPLATE, + AGENT_TIDE_SYSTEM_PROMPT, CALMNESS_SYSTEM_PROMPT, CMD_BRAINSTORM_PROMPT, CMD_CODE_REVIEW_PROMPT, CMD_TRIGGER_PLANNING_STEPS, CMD_WRITE_TESTS_PROMPT, GET_CODE_IDENTIFIERS_SYSTEM_PROMPT, README_CONTEXT_PROMPT, REJECT_PATCH_FEEDBACK_TEMPLATE, REPO_TREE_CONTEXT_PROMPT, STAGED_DIFFS_TEMPLATE, STEPS_SYSTEM_PROMPT, WRITE_PATCH_SYSTEM_PROMPT ) from .utils import delete_file, parse_blocks, parse_steps_markdown, trim_to_patch_section @@ -70,6 +70,8 @@ def pass_custom_logger_fn(self)->Self: async def get_repo_tree_from_user_prompt(self, history :list)->str: history_str = "\n\n".join([str(entry) for entry in history]) + for CMD_PROMPT in [CMD_TRIGGER_PLANNING_STEPS, CMD_WRITE_TESTS_PROMPT, CMD_BRAINSTORM_PROMPT, CMD_CODE_REVIEW_PROMPT]: + history_str.replace(CMD_PROMPT, "") ### TODO evalutate sending last N messages and giving more importance to ### search results from latter messages @@ -82,7 +84,7 @@ async def get_repo_tree_from_user_prompt(self, history :list)->str: codeSearch = SmartCodeSearch(documents=nodes_dict) await codeSearch.initialize_async() - results = await codeSearch.search_smart(history_str, top_k=5) + results = await codeSearch.search_smart(history_str, top_k=15) self.tide.codebase._build_tree_dict([doc_key for doc_key,_ in results] or None)