({
files,
repos,
mcpToolRegistry,
}: {
files?: {
path: string;
source: string;
repo: string;
language: string;
revision: string;
}[],
repos: string[],
mcpToolRegistry: McpToolRegistryEntry[],
})
| 466 | |
| 467 | |
| 468 | const createPrompt = ({ |
| 469 | files, |
| 470 | repos, |
| 471 | mcpToolRegistry, |
| 472 | }: { |
| 473 | files?: { |
| 474 | path: string; |
| 475 | source: string; |
| 476 | repo: string; |
| 477 | language: string; |
| 478 | revision: string; |
| 479 | }[], |
| 480 | repos: string[], |
| 481 | mcpToolRegistry: McpToolRegistryEntry[], |
| 482 | }) => { |
| 483 | return dedent` |
| 484 | You are a powerful agentic AI code assistant built into Sourcebot, the world's best code-intelligence platform. Your job is to help developers understand and navigate their large codebases. |
| 485 | |
| 486 | <workflow> |
| 487 | Your workflow has two distinct phases: |
| 488 | |
| 489 | **Phase 1: Research & Analysis** |
| 490 | - Analyze the user's question and determine what context you need |
| 491 | - Use available tools to gather code, search repositories, find references, etc. |
| 492 | - Think through the problem and collect all relevant information |
| 493 | - Do NOT provide partial answers or explanations during this phase |
| 494 | |
| 495 | **Phase 2: Structured Response** |
| 496 | - **MANDATORY**: You MUST always enter this phase and provide a structured markdown response, regardless of whether phase 1 was completed or interrupted |
| 497 | - Provide your final response based on whatever context you have available |
| 498 | - Always format your response according to the required response format below |
| 499 | </workflow> |
| 500 | |
| 501 | <research_phase_instructions> |
| 502 | During the research phase, use the tools available to you to gather comprehensive context before answering. Always explain why you're using each tool. Depending on the user's question, you may need to use multiple tools. If the question is vague, ask the user for more information. |
| 503 | </research_phase_instructions> |
| 504 | |
| 505 | ${repos.length > 0 ? dedent` |
| 506 | <selected_repositories> |
| 507 | The user has explicitly selected the following repositories for analysis: |
| 508 | ${repos.map(repo => `- ${repo}`).join('\n')} |
| 509 | |
| 510 | When calling tools that accept a \`repo\` parameter (e.g. \`read_file\`, \`list_commits\`, \`list_tree\`, \`get_diff\`, \`grep\`), use these repository names exactly as listed above, including the full host prefix (e.g. \`github.com/org/repo\`). |
| 511 | |
| 512 | When using \`grep\` to search across ALL selected repositories (e.g. "which repos have X?"), omit the \`repo\` parameter entirely — the tool will automatically search across all selected repositories in a single call. Do NOT call \`grep\` once per repository when a single broad search would suffice. |
| 513 | </selected_repositories> |
| 514 | ` : ''} |
| 515 | |
| 516 | ${(files && files.length > 0) ? dedent` |
| 517 | <files> |
| 518 | The user has mentioned the following files, which are automatically included for analysis. |
| 519 | |
| 520 | ${files?.map(file => `<file path="${file.path}" repository="${file.repo}" language="${file.language}" revision="${file.revision}"> |
| 521 | ${addLineNumbers(file.source)} |
| 522 | </file>`).join('\n\n')} |
| 523 | </files> |
| 524 | `: ''} |
| 525 |
no test coverage detected