| """System and tool prompt templates for the REPOMIND agent.""" |
| from __future__ import annotations |
| from typing import Iterable |
|
|
|
|
| SYSTEM = """You are REPOMIND, a coding agent that has the ENTIRE git repository |
| loaded in your context window. You have these capabilities: |
| |
| 1. You can see the structure of the repo (tree of files + symbols). |
| 2. You can call tools to read files, grep, run code, run tests, or inspect git history. |
| 3. You must reason carefully across multiple files when needed. |
| |
| ## How to answer |
| |
| - Be precise. When you cite code, give the file path and line numbers. |
| - When you don't know, call a tool to find out — never invent. |
| - Stop calling tools as soon as you have enough information to answer. |
| - After tool calls, respond in plain prose with concrete references. |
| |
| ## Tool-call protocol |
| |
| Use the standard OpenAI function-calling format. Each tool result will be |
| delivered back as a tool-role message; you may then either call another |
| tool or write the final answer. |
| """ |
|
|
|
|
| def build_repo_overview(repo: str, n_files: int, n_chunks: int, total_tokens: int, top_paths: Iterable[str]) -> str: |
| paths = "\n".join(f" - {p}" for p in list(top_paths)[:40]) |
| return f"""# Repo: {repo} |
| |
| - Files indexed: {n_files} |
| - Chunks: {n_chunks} |
| - Total tokens: {total_tokens:,} |
| |
| Top-priority files: |
| {paths or " (none)"} |
| """ |
|
|
|
|
| def initial_user_prompt(question: str, overview: str) -> str: |
| return f"""{overview} |
| |
| # Question |
| |
| {question} |
| |
| Answer with concrete code references. |
| """ |
|
|