File size: 1,489 Bytes
e3a472a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""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.
"""